MonkeyOnARock MonkeyOnARock - 5 months ago 6
Javascript Question

How to add a number variable to an object in a different variable

var count = 0;
var price = req.body.price + count;


In the above example I want the variable price to be equal to req.body.price0. How can I do that?

Answer

I think

var price = req.body['price' + count];

should do the job

See also here for more information about that