Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
It's good you've found working solution. Take a look at Matija7's answer to see cleaner solution.
Nice.
Regarding var result = 0;
You can just declare result variable. IMHO this is better option for readability of your code.
var result;
Or you can initialize it to default value and loose else block.
var result = null;
However, you could improve formatting.
result= a + b;
=>result = a + b;
Closing if and elese if block brace should be aligned with block key word.
You don't need last return statement
return result;
since all your if statement blocks return value;