I got a dict object structure like this:
var dict = {
11: 0,
12: 0,
13: 0
...
};
I want to do this:
for (var i = 11; i < 42; i++) {
dict.Add(i, 0);
}
But I do know "Add()" is not a function defined on the dict object.
So, how can I do it insead of manully write 11~42 line by line?
I got a dict object structure like this:
var dict = {
11: 0,
12: 0,
13: 0
...
};
I want to do this:
for (var i = 11; i < 42; i++) {
dict.Add(i, 0);
}
But I do know "Add()" is not a function defined on the dict object.
So, how can I do it insead of manully write 11~42 line by line?
Share Improve this question asked Dec 5, 2013 at 5:46 Edi WangEdi Wang 3,6376 gold badges36 silver badges51 bronze badges 1- Exactly the same way you would index an array. – user229044 ♦ Commented Dec 5, 2013 at 5:48
1 Answer
Reset to default 12Is this what you are looking for?
for (var i = 11; i < 42; i++) {
dict[i] = 0;
}
If you want to include 42
per your question, then change the <
to a <=
.