What is the correct way to convert value of String variable to int/numeric variable? Why is bcInt still string and why does isNaN return true?
bc=localStorage.getItem('bc');
var bcInt=parseInt(bc,10);
var bcInt2=1;
console.log("bc------------>" +bc +" isNaN:" +isNaN(bc)); //isNaN returns true
console.log("bcInt------------>" +bcInt +" isNaN:" +isNaN(bcInt)); //isNaN returns true
bcInt2// isNaN returns false
parseInt()returns aNaN, then your string doesn't actually contain a numeric representation of a value. If you had told us what the value of "bc" is, then perhaps somebody could help, but you failed to do that. That value is of course the key to the whole problem.bc? If it is not a number (empty, got alpha characters etc...), that's what I would expect to see.1then it's not going to work.