Skip to content

Instantly share code, notes, and snippets.

@Slackwise
Last active July 19, 2019 17:33
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 Slackwise/8a5dad0ba23320cbf20f87fcbdf43115 to your computer and use it in GitHub Desktop.
Save Slackwise/8a5dad0ba23320cbf20f87fcbdf43115 to your computer and use it in GitHub Desktop.
There was a challenge someone mentioned of implementing addition without using the `+` operator... CHALLENGE ACCEPTED!
function add(x, y) {
const apiUrl = `https://api.mathjs.org/v4/?expr=${x}%2B${y}`;
try {
let xhr = new XMLHttpRequest(apiUrl);
xhr.open('GET', apiUrl, false);
xhr.send();
return Number(xhr.responseText);
} catch (ex) {
console.log("Ya'll numbers fucky");
return NaN;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment