Creating a wave of string in Javascript

You could take an outer loop for visiting the characters and if a non space character is found, create a new string with an uppercase letter at this position.

function wave(string) {
    var result = [],
        i;

    for (i = 0; i < string.length; i++) {
        if (string[i] === ' ') continue;
        result.push(Array.from(string, (c, j) => i === j ? c.toUpperCase() : c).join(''));
    }
    return result;
}

console.log(wave("hello"));   // ["Hello", "hEllo", "heLlo", "helLo", "hellO"]
console.log(wave(" h e y ")); // [" H e y ", " h E y ", " h e Y "]
console.log(wave(""));        // []
.as-console-wrapper { max-height: 100% !important; top: 0; }