I am trying to add an integer and an array element(also integer) but I seem to be concatenating them instead. How would I add the two together?
i = 0;
var1 = 0;
var2 = prompt("please enter 5 integers separated by commas");
//1,2,3,4,5
var2.split(',');
for (i=0;i<5;i++){
var1 += var2[i];
}
EDIT: Apologies I forgot something that's probably very important. I'll add that now. added the prompt and the split.
var2 = [1,2,3,4,5]and you're good