var txt = '54839257+32648-34324';
var x;
for (x of txt) {
if (0||1||2||3||4||5||6||7||8||9) {
var con = Number(x);
} else { x.toString();}
document.write(con);
}
In the code above i want to convert the digits inside the string to number but not plus and minus signs. I want to have them together for the result. like this: 54839257+32648-34324
.
But my code gives this: 54839257NaN32648NaN34324
.