Last active
July 19, 2019 17:33
-
-
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!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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