let str = 'react';
let newStr = str.split('');
const final = newStr.forEach((word,i) =>{
const rep = word.repeat(i) + word;
console.log(rep);
})
i already did repeat it but i want to have this output { react eeact aaact cccct ttttt } not this {r ee aaa cccc ttttt}
Something like this
const str = 'react';
const newStr = str.split('');
const final = newStr.map((word,i,a) => [word.repeat(i), ...a.slice(i)].join(''));
console.log(final);