← Back to challenges

Math Marking

JavaScriptHardarraysstringsformattingmath

Instructions

Given an array of math equations (given as strings), return the percentage of correct answers as a string. Round to the nearest whole number.

Examples

markMaths(["2+2=4", "3+2=5", "10-3=3", "5+5=10"]) ➞ "75%"

markMaths(["1-2=-2"]), "0%"

markMaths(["2+3=5", "4+4=9", "3-1=2"]) ➞ "67%"

Notes

  • You can expect only addition and subtraction.
  • Note how there aren't any spaces in any given equation.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.