Reputation: 432
do you know how to convert an array of strings to one integer?
Example:
var array = ["1","2","3","4"];
to
var number = 1234;
Upvotes: 2
Views: 82
Reputation: 36511
Here you go, just need to join the array and parse the integer out:
var array = ['1', '2', '3', '4'];
var number = parseInt(array.join(''), 10);
alert(number);
Note: The 10 used in the parseInt
function above is to specify the radix
(also known as the base in mathematical numeral systems). 10 signifies the base used in decimal system.
Upvotes: 7