Skip to main content
added a commented version
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

JavaScript (ES6), 24 bytes

Note that it works because Set is guaranteed to maintain the insertion order of its elements.

s=>[...new Set(s)].pop()

Try it online!

Commented

s =>         // s = input string
[...         // turn into an array ...
  new Set(s) //   ... the set generated from s
             //       e.g. "BANANA" -> Set {'B','A','N'}
]            //
.pop()       // return the last element

JavaScript (ES6), 24 bytes

Note that it works because Set is guaranteed to maintain the insertion order of its elements.

s=>[...new Set(s)].pop()

Try it online!

JavaScript (ES6), 24 bytes

Note that it works because Set is guaranteed to maintain the insertion order of its elements.

s=>[...new Set(s)].pop()

Try it online!

Commented

s =>         // s = input string
[...         // turn into an array ...
  new Set(s) //   ... the set generated from s
             //       e.g. "BANANA" -> Set {'B','A','N'}
]            //
.pop()       // return the last element
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

JavaScript (ES6), 24 bytes

Note that it works because Set is guaranteed to maintain the insertion order of its elements.

s=>[...new Set(s)].pop()

Try it online!