← Back to challenges

Check if the Formula is Correct

JavaScriptHardalgebramathnumbersvalidation

Instructions

Create a function that takes a string and returns true or false depending on whether or not the formula is correct.

Examples

formula("6 * 4 = 24") ➞ true

formula("18 / 17 = 2") ➞ false

formula("") ➞ undefined

Notes

  • You have to figure out what a is.
  • Ignore the spaces.
  • If the input is an empty string "", return undefined.
  • You do not need to dynamically find the value of a (it's a constant and the same accross all tests).
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.