Skip to content

Instantly share code, notes, and snippets.

@rowlandekemezie
Created February 21, 2017 10:19
Show Gist options
  • Save rowlandekemezie/d685bc2dff236b5edb9a0f2d9bc2cce3 to your computer and use it in GitHub Desktop.
Save rowlandekemezie/d685bc2dff236b5edb9a0f2d9bc2cce3 to your computer and use it in GitHub Desktop.
Reactor created by rowland - https://repl.it/FqqB/1
function test (num) {
var holder = num.split('');
var sum = 0, i = 0;
var count = holder.length;
while(i < count) {
if(holder[i] === '-'){
sum = sum - holder[i + 1];
i += 2;
} else{
sum += parseInt(holder[i]);
i++;
}
}
return sum;
}
test('-4378384');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment