Creating an Equation Solver

You just need to write your functions inside the script block (between <script> and </script>, replacing //JavaScript code goes herewith your code.

You have to define the three functions used in the onclick events of the buttons.
ClickMe(), Submit() and Reset()

Defining functions in Javascript

Clickme should get a random element from an array

Maybe you’ll need also some dom manipulation function to add the content of the equation somewhere

Submit() needs to get some input and compare it to the expected result, so you’ll need some input fields on your submit form

Or you should prompt the user to input the answer

As you are checking the answer to be valid. You’ll need to check evaluating the equation exposed and maybe you need eval but remember

eval is evil

Your Reset() function just needs to reload the page
How to reload a page using JavaScript

Browse More Popular Posts

Leave a Comment