Your code has two small errors. See:
var mult = data.qtd++;
The way it is, how you’re using post increment operator, you’re basically doing this:
var mult = data.qtd;
data.qtd++;
Hence the value of mult
stays 0
and when doing the multiplication, logically will return 0
also.
If you do not want to change the value of data.qtd
try to do so:
var mult = data.qtd + 1;
But if you really need to change the value of data.qtd
, you can do so:
var mult = ++data.qtd;
This way you change the value of the variable and then with the updated value you assign it.
And in the last code snippet of the function add()
mult * data.vlr_produto
You are multiplying right, but you are doing nothing but multiply, the result of multiplication is being "lost". Since you’re not doing anything with it, you’re not assigning in a variable, you’re not returning, you’re not printing.
OBS: In that reply, i explain a little how the post operator works and pre trouble.