Example input: "I'm so happy it's Monday"
Example output: "I'M So hApPy iT'S MoNdAy"
*/
function altCaps(str){
const newStr = [];
const strSplit = str.split('');
console.log(strSplit)
for(let i = 0; i < strSplit.length; i++) {
if(i % 2 == 0 ) {
newStr.push(strSplit[i].toUpperCase());
} else {
newStr.push(strSplit[i].toLocaleLowerCase());
}
}
return newStr.join('');
}
console.log(altCaps("When you visit Portland you have to go to VooDoo Donuts"));
console.log(altCaps("I'm so happy it's Monday"));
/* Alternating Caps
Write a function that takes in a string of letters
and returns a sentence in which every other letter is capitalized.