I have this function: when a user fill a field with this “c 10 20 30” i need to sum just the numbers and show the result.
I have this but is NOT working…
function escaja(str, prefix) {
if (str.indexOf(prefix)===0){
var sumar = str.split(" ");
var sumar1 = 0;
for(i = 0; i < sumar.length; i++){
if (!isFinite(sumar1)) {
sumar1 = Number(sumar[i]+sumar1);
}
}
Any idea…???