I take on input string "ZpglnRxqenU"
and must return string with that view
"Z-Pp-Ggg-Llll-Nnnnn-Rrrrrr-Xxxxxxx-Qqqqqqqq-Eeeeeeeee-Nnnnnnnnnn-Uuuuuuuuuuu"
i almost done, but i don't know why first letter in array elements don't change to upper case.
function accum(s) {
let str = s.toLowerCase();
let arr = [];
for(let i=0; i<str.length;i++){
arr.push(str[i].repeat(i+1));
arr[i][0].toUpperCase();
}
return arr.join('-');
}
console.log(accum("ZpglnRxqenU"));
// must be "Z-Pp-Ggg-Llll-Nnnnn-Rrrrrr-Xxxxxxx-Qqqqqqqq-Eeeeeeeee-Nnnnnnnnnn-Uuuuuuuuuuu"