Having trouble adding a value to an element array. An example of what I currently have.
array[1] current example is value of 10
var total = array[1] + 1; // result is 101
I need total to be 11, I also tried the bellow example, same thing.
var total = array[1].toString() + 1; // result 101
Convert the string to Number before the addition otherwise, string concatenation will happen.
var total = +array[1] + 1;
Refer : How do I convert a string into an integer in JavaScript?
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments