I have a variable that contains a few comma seperated values. I'd like to split these up and push them into an array as integers only I can't figure it out.
I've the following...
globArr = [];
arr = "1,4,3,2,4,2,4";
var answ = arr.split(',');
globArr.push(parseInt(answ));
console.log(globArr);
https://jsfiddle.net/d7hke7gq/
Can anybody tell me where im going wrong?
arr = "1,4,3,2,4,2,4";var answ = arr.split(',');console.log(answ);. very simpleparseIntdo in this context? getting a number or getting an integer number?globArr = []; var arr = "1,4,3,2,4,2,4"; var answ = arr.split(','); for(var i = 0; i < answ.length; i++) { globArr.push(parseInt(answ[i])); console.log(answ[i]); } console.log(globArr);