Find First Character That Repeats

Published by BijogFc24 in

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

Examples

firstRepeat("legolas") ➞ "l"

firstRepeat("Gandalf") ➞ "a"

firstRepeat("Balrog") ➞ "-1"

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

Notes

Tests are case sensitive.

Watch a quick demo on how Edabit works.