Alternative Kapitalisierung
// Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index 0 will be considered even.
// For example, capitalize("abcdef") = ['AbCdEf', 'aBcDeF']. See test cases for more examples.
// The input will be a lowercase string with no spaces.
const capitalize = s => {
s = s.split('')
let finalArr = []
let i = 0
while(i < 2){
let str = ''
s.forEach((letter, index) => {
if(i % 2 === 0 && index % 2 === 0) str += letter.toUpperCase()
else if(i % 2 !== 0 && index % 2 !== 0) str += letter.toUpperCase()
else str += letter
} )
finalArr.push(str)
i++
}
return finalArr
};
console.log(capitalize("abcdef"))
// With love @kouqhar
kouqhar