I am getting a strange error, could somebody help me fix this out?
const myArray = new Array(4)
.keys()
.map((v, i) => (
console.log('print:', v, i)
)
)
console.log('myArray print: ', myArray);
I am getting this error:
TypeError: (intermediate value).keys(...).map is not a function
update:
i want to use the i
to look up some stuff from another existing array.
const myArray = new Array(4)
.keys()
.map((v, i) => ({
name: i
})
)
console.log('myArray print: ', myArray);
edit:
this question is not a duplicate, It is trying to iterate over a certain number and create a new object using the iterations.