Find First Character That Repeats

Published by Mubashir Hassan in

Create a function that takes a string and returns the first character that repeats. If there is no repeat of a character, return "0".

Examples

firstRepeat("legolas") ➞ "l"

firstRepeat("Gandalf") ➞ "a"

firstRepeat("Balrog") ➞ "0"

firstRepeat("Isildur") ➞ "0"
// Case sensitive "I" not equal to "i"

Notes

Tests are case sensitive.

Watch a quick demo on how Edabit works.