The examples below show you how to write function accum:
Examples:
The parameter of accum is a string which includes only letters from a..z and A..Z.
My code:
function accum(s) {
let split = s.split('');
let result = [];
for (let i = 0; i < split.length; i++) {
let char = split[i].toUpperCase();
let repeatedChar = char + split[i].toLowerCase().repeat(i);
result.push(repeatedChar);
}
return result.join('-');
}
function accum(s) {
return s.split('').map((c, i) => (c.toUpperCase() + c.toLowerCase().repeat(i))).join('-');
}