so I've wrote this function, i want to uppercase the vowels and lowercase every other letter, problem the end result ends with the same string, I'm new to spread and for-each, after i spread a string does it become an array? when i manipulate letters does it suppose to become a string again with the manipulations or do i need to join it? why aren't the upper and lowercase functions don't work?
the function:
function upperCase(str) { var vowels = "aeiou"; [...str].forEach(letter => { if (vowels.includes(letter)) letter.toUpperCase(); letter.toLowerCase(); }); console.log(str); }
forEach. And notice thattoUpperCase()does not change a string (or char), it returns a new one. So build a new string that you canreturn(or log) in the end.mapto a new array and then.join("")the letters back to a string.