word and a letter letter. Find the first occurrence of letter in the word and reverse the part from the start of the word up to and including that letter. Everything after it stays as is.
If letter does not occur in the word, return the word unchanged.word='planet', letter='n' → 'nalpet'
The first n is at index 3. The head plan turns into nalp and the tail et stays: nalpet.
word='banana', letter='a' → 'abnana'
Only the first a (index 1) matters: ba becomes ab and the rest is untouched, giving abnana.
word='river', letter='x' → 'river'
There is no x in the word, so it comes back unchanged.
word.length ≤ 250word consists of lowercase English lettersletter is a single lowercase English letterword='planet', letter='n'
'nalpet'
Run checks the first 3 tests in your browser. Submit checks all 135 tests on the server, hidden ones included.