Hi all i have this loop which will loop 4 times.
for (var i = 0; i < 4; i++){
var d = [[1111,2222],[3333,4444]]
}
below is my expect output , thank you every much all.
var expected = [
[
[1111,2222],[3333,4444]
],
[
[1111,2222],[3333,4444]
],
[
[1111,2222],[3333,4444]
],
[
[1111,2222],[3333,4444]
]
]
Is that what you tried to achieve?
const output = [];
const input = [[1111,2222],[3333,4444]]
for (var i = 0; i < 4; i++){
output.push(input)
}
console.log(output) // [[[1111,2222],[3333,4444]], [[1111,2222],[3333,4444]], [[1111,2222],[3333,4444]], [[1111,2222],[3333,4444]]]
You can get the result like this
function getNewArray() {
var newArray = []
for (var i = 0; i < 4; i++){
var d = [[1111,2222],[3333,4444]]
newArray.push(d)
}
return newArray;
}
let expected = getNewArray()