MonkeyOnARock MonkeyOnARock - 1 year ago 56
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 Source

I think

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

should do the job

See also here for more information about that

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download