I am trying to iterate over the original string 3 times. The result I get is: ["a","b","c","d",undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined]
The correct result should be: ["a", "b", "c", "d", "a", "b", "c", "d", "a", "b", "c", "d"]
function makeCopies (str, howmany) {
let newCopy = [];
for(let i = 0; i < str.length * howmany; i++) {
newCopy.push(str[i])
}
return newCopy;
}
console.log(makeCopies("abcd", 3))
I have tried many variations but nothing works, this is the closest I got.