I want to loop to do something like this
const firstColumn = {};
for (let index = 1; index < 20; index++) {
firstColumn[index] = {}
}
I want to end with something like this
const data = {
"1": {},
"2": {},
"3": {},
// So on
}
But I'm getting this console output.
Object {
"1": Object {},
"10": Object {},
"11": Object {},
"12": Object {},
"13": Object {},
"14": Object {},
"15": Object {},
"16": Object {},
"17": Object {},
"18": Object {},
"19": Object {},
"2": Object {},
"3": Object {},
"4": Object {},
"5": Object {},
"6": Object {},
"7": Object {},
"8": Object {},
"9": Object {},
}
the Funny thing if I limit the loop iteration to less than 10 I get the right sequence.
for (let index = 1; index < 10; index++) {
firstColumn[index] = {}
}
// output
Object {
"1": Object {},
"2": Object {},
"3": Object {},
"4": Object {},
"5": Object {},
"6": Object {},
"7": Object {},
"8": Object {},
"9": Object {},
}
I honestly don't get it. Maybe somebody smarter than me can help me. Thanks in advance.