0
I have a repeating structure that should add some values:
The variable qtdeEstoque
was defined as number
and the variable variacaoForm.value.variacoes.estoque_variacao
is a number, but when I try to add it this way instead of increasing the value it puts in front, for example: number 10
and 5
, he joins and gets 105
:
for(let i=0;i<this.variacaoForm.value.variacoes.length;i++){
this.qtdeEstoque+= this.variacaoForm.value.variacoes[i].estoque_variacao
}
console.log(this.qtdeEstoque);
I tried some other ways using toInt()
and Number()
:
for(let i=0;i<this.variacaoForm.value.variacoes.length;i++){
this.qtdeEstoque+= Number(this.variacaoForm.value.variacoes[i].estoque_variacao)
}
console.log(this.qtdeEstoque);
But he returns NAN
, how can I fix this?
Do you have an example of data for testing? Ex: 15.45
– Laerte
the values are int, as specified in the post, if you put 10 and 5 it concatenates and gets 105, and using toInt() and Number() returns NAN
– veroneseComS
How did you define this property?
– Eduardo Vargas
pq she took down vote?
– Willian