Mexican Wave

Instructions: In this simple Kata your task is to create a function that turns a string into a Mexican Wave. You will be passed a string and you must return that string in an array where an uppercase letter is a person standing up. Rules: The input string will always be lower case but maybe empty. If the character in the string is whitespace then pass over it as if it was an empty seat Example: wave("hello") => ["Hello", "hEllo", "heLlo", "helLo", "hellO"] Thoughts: I decided to play around with strings at this challenge and use the replace() function to change the lower case letter to the upper case based on the index. 1st Attempt: Output: As you can see the code works great on the codewars input, but on the hello fails. This is a CodeWars Challenge of 6kyu Rank (https://www.codewars.com/kata/58f5c63f1e26ecda7e000029/train/javascript)

Apr 7, 2025 - 17:48
 0
Mexican Wave

Instructions:
In this simple Kata your task is to create a function that turns a string into a Mexican Wave. You will be passed a string and you must return that string in an array where an uppercase letter is a person standing up.
Rules:

  1. The input string will always be lower case but maybe empty.

  2. If the character in the string is whitespace then pass over it as if it was an empty seat
    Example:
    wave("hello") => ["Hello", "hEllo", "heLlo", "helLo", "hellO"]

Thoughts:

  1. I decided to play around with strings at this challenge and use the replace() function to change the lower case letter to the upper case based on the index.

1st Attempt:
1st Attempt

Output:

1st Output
As you can see the code works great on the codewars input, but on the hello fails.

This is a CodeWars Challenge of 6kyu Rank (https://www.codewars.com/kata/58f5c63f1e26ecda7e000029/train/javascript)