Skip to content

Instantly share code, notes, and snippets.

@siddharthray
Created January 4, 2018 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siddharthray/3896f2068ac7dc33a70588d87bf66b9e to your computer and use it in GitHub Desktop.
Save siddharthray/3896f2068ac7dc33a70588d87bf66b9e to your computer and use it in GitHub Desktop.
JavaScript miscellaneous
let calculate = (no1, no2, operation) => {
let result;
switch (operation) {
case 'add':
result = no1 + no2;
break;
case 'subtract':
result = no1 - no2;
break;
}
return result;
};
console.log(calculate(2,2,'add'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment