Question: * 20 pts: Build an HTML document and paste the markup and script below in your document. * 70 pts: Write the JavaScript to perform
* 20 pts: Build an HTML document and paste the markup and script below in your document.
* 70 pts: Write the JavaScript to perform the required mathematical operation over the two
numbers passed into the method.
For example, if the operator is "+", num1 is 2 and num2 is 1, then add the two
numbers together and store the calculation in "result."
e.g. result = num1 + num2
Be sure to only write your code in the area specified. Do not modify any other script
t
HINT let number = 2;
if (number == 1) {
console.log("Number is 1!");
} else if (number == 2) {
console.log("Number is 2!");
} else if (number == 3) {
console.log("Number is 3!");
}
LAST STEP* Upload your HTML file to Teams and click the Turn In button.
Week 6 Lab 1
// Given four mathematical operations +-*/
// Write the JavaScript to compute the solution
// Save the computation in the variable named result.
function calculate(num1, num2, operator) {
let result = "";
// Your Code Starts Here
// Your Code Ends Here
return result;
}
report(calculate(2,1,"+"),2,1,"+");
report(calculate(2,1,"-"),2,1,"-");
report(calculate(2,4,"*"),2,4,"*");
report(calculate(2,4,"/"),2,4,"/");
function report(solution, num1,num2,operator) {
console.log(`${num1} ${operator} ${num2} = ${solution}`);
}
Confused on this! I'm doing it in eclipse!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
