Find the First Non-Repeated Character

Published by Matt in

Create a function that accepts a string as an argument and returns the first non-repeated character.

Examples

first_non_repeated_character("g") ➞ "g"

first_non_repeated_character("it was then the frothy word met the round night") ➞ "a"

first_non_repeated_character("the quick brown fox jumps then quickly blows air") ➞ "f"

first_non_repeated_character("hheelloo") ➞ false

first_non_repeated_character("") ➞ false

Notes

  • An empty string should return false.
  • If every character repeats, return false.
  • Don't worry about case sensitivity or non-alphanumeric characters.
Watch a quick demo on how Edabit works.