DEV Community

loading...

Discussion on: Daily Challenge #210 - Separate Capitalization

Collapse
ravikiranjs profile image
Ravi Kiran

var capitalize = (word) => {
const split = word.split('');
const firstWord = split.map( (a, i) => i%2 === 0 ? a.toUpperCase() : a)
const secondWord = split.map( (a, i) => i%2 !== 0 ? a.toUpperCase() : a)
return [firstWord.join(''), secondWord.join('')];
}

capitalize('abcdef')