While doing the Whale Talk project, I noticed I’m not able to capitalize items in the array until after I join them.
const input = 'Sunshine and Roses and I love you to the moon and back';
let vowels = ['a', 'e', 'i', 'o', 'u'];
const resultArray = [];
for (let inputIndex = 0; inputIndex < input.length; inputIndex++) {
//console.log(inputIndex) -- 17
if (input[inputIndex] === 'e') {
resultArray.push(input[inputIndex]);
}
if (input[inputIndex] === 'u') {
resultArray.push(input[inputIndex]);
}
for (let vowelsIndex = 0; vowelsIndex < vowels.length; vowelsIndex++) {
//console.log(`vowelsIndex is ${vowelsIndex}`)
if (input[inputIndex] === vowels[vowelsIndex])
// console.log(input[inputIndex])
resultArray.push(input[inputIndex])
// console.log(resultArray)
}
}
console.log(resultArray.join('').toUpperCase());
This is the correct form.
This is what I tried first:
console.log(resultArray.join(’’).toUpperCase());
This also didn’t work:
console.log(resultArray.toUpperCase());
What if I wanted to capitalize the items in the array and NOT join? What am I doing wrong?