Answer the question
In order to leave comments, you need to log in
Adding a value to a variable with the same name as the key?
There is a json record with keys the same as variables.
How to add to a variable a number that is equal to the value of a key with the same name as the variable?
{
"x": 3
"y": 2
"z": 1
}
let x = 0
let y = 0
let z = 0
for (var key in json) {
switch (key) {
case "x":
x += json[key]
break;
//etc
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question