let str = 'react'; let newStr = str.split(''); const final = newStr.forEach((word,i) =>{ const rep = word.repeat(i) + word; console.log(rep); })ya lo repetí pero quiero tener esta salida {reaccionar eeact aaact cccct ttttt} no esto {r ee aaa cccc ttttt}
Algo como esto
const str = 'react'; const newStr = str.split(''); const final = newStr.map((word,i,a) => [word.repeat(i), ...a.slice(i)].join('')); console.log(final);