In this challenge we have created a client-side script using HTML, CSS and JavaScript to help a Maths teacher create homework worksheets for their class.
Our HTML page uses a web form, for the teacher to select various options based on the Maths skills they want to cover and the desired level of difficulty.
The JavaScript code attached to the âCreate Worksheetâ button is retrieving the user inputs from the various drop down lists. It then uses these to generate list of arithmetic equations and display these on the HTML page
Reverse engineer this JavaScript code to understand how it works. For instance can you identify:
The purpose of the getDropDownListValue() function defined on lines 1 to 4?
The purpose of lines 7 to 49?
The purpose of the switch case on lines 12 to 33?
The purpose of the for loop on line 37?
The purpose of lines 38, 39 and 40?
The purpose of line 42?
The purpose of line 44?
Challenge #1: 2 or 3 operands per equation?
Now that you understand how this code works, complete it in order for the Maths teacher to be able to chose the number of operands per equations. For instance, if the Maths teacher chooses two operands it will generate equations such as â2+7â. If the teacher chooses three operands, an example of equation could be â2+4-7â.
Challenge #2: Find the missing operand
Change the code to generate equations with a missing operand. For instance: â2 + ??? = 9â
Challenge #3: Linear Equations
Change the code to generate linear equations. For instance: â3x + 2 = 11â
Challenge #4: Quadratic Equations
Change the code to generate quadratic equations. For instance: â4x2 + 5x + 2 = 0âģ