mexican wave

kata 7

by trentHarlem

JavaScript

function wave(str) {
  let newArr = []
  for (let i = 0; i < str.length; i++) {
    let word = str.split('')
    if (word[i] !== ' ') {
      word[i] = word[i].toUpperCase()
      newArr.push(word.join(''))
    }
  }
  return newArr
}


/* function wave(str) {
//let string = str.trim()
  let array = []
  let array2 = []
  for (let i = 0; i < str.length; i++) {
    array.push(str)
  }
array.forEach((word, i) => {
if(word[i]!== ' ')
array2.push(word.replace(word[i], word[i].toUpperCase()))
})
  return array2
} */

//console.log(wave("hello")) 
 
//console.log(wave(" gap "))
console.log(wave("two words"))