Check if the Formula is Correct

Published by Ruud Peter Boelens in

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).
Watch a quick demo on how Edabit works.