Skip to content

Instantly share code, notes, and snippets.

@LevitatingBusinessMan
Last active September 9, 2019 09:57
Show Gist options
  • Select an option

  • Save LevitatingBusinessMan/f03bfe725b458cd828da87376a6fa8b4 to your computer and use it in GitHub Desktop.

Select an option

Save LevitatingBusinessMan/f03bfe725b458cd828da87376a6fa8b4 to your computer and use it in GitHub Desktop.
Math class was boring so I spend my time making this instead
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