Last active
September 9, 2019 09:57
-
-
Save LevitatingBusinessMan/f03bfe725b458cd828da87376a6fa8b4 to your computer and use it in GitHub Desktop.
Math class was boring so I spend my time making this instead
This file contains hidden or 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
| if (process.argv.length < 3) | |
| return console.log("No equation defined") | |
| const equation = process.argv[2] | |
| if (!equation.includes("=") || !equation.includes("x")) | |
| return console.log("Not a valid equation") | |
| const firstHalf = equation.split("=")[0] | |
| const secondHalf = equation.split("=")[1] | |
| if (!firstHalf.includes("x")) { | |
| let temp = secondHalf | |
| secondHalf = firstHalf | |
| fistHalf = temp | |
| } | |
| for (let i=-1000000; i <=1000000; i++) { | |
| x = i/1000 | |
| if (eval(firstHalf) == eval(secondHalf)) | |
| console.log(`x=${x}`) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment