subject

There are several syntax errors in the code that are preventing this calculator from working, find and fix those errors. When they are fixed, the number buttons will all work, as well as the + (add) and -- (decrement) buttons. To find the errors, open up the Developers Tool of the browser (F12) and look at the console.
Find the line number of the file and click on it to see the source code and find the error
There are 4 errors in the JavaScript file and 1 error in HTML file
Verify the "add" functionality works. For a binary operator, you must click on the buttons in the following order:
Hit a number button
Hit the ‘+’ button
Hit a number button
Hit the ‘Calculate’ button
Verify the decrement operator works. For a unary operator, you must click the buttons in the following order:
Hit the number button
Hit the ‘—‘ button
Implement subtraction in a similar fashion to addition:
Create a subtract function. To subtract, the user must hit a number button, then the ‘-‘ button, another number button and then the ‘Calculate’ button. The function should store the first number in a global variable, similar to the add function.
Add code in the calculate button which will perform the subtraction when the ‘Calculate’ button is clicked.
Call the subtract function from the HTML file.
Implement the sqrt() button. Similar to the decrement function, the sqrt() button will take the value of the number and display the square root. Use the Math. sqrt function to calculate the square root.
Code :
//Global variables

var prevCalc = 0;
var calc = "";
//The following function displays a number in the textfield when a number is clicked.
//Note that it keeps concatenating numbers which are clicked.
function showNum(value) {
document. frmCalc. txtNumber. value += = value;
}
//The following function decreases the value of displayed number by 1.
//isNaN method checks whether the value passed to the method is a number or not.
function decrement() {
var num = parseFloat(document. frmCalc. txtNumber. value);
if (!(isNaN(num))) {
num--;
document. frmCalc. txtnumber. value = num;
}
}
//The following function is called when "Add" button is clicked.
//Note that it also changes the values of the global variables.
function add() {
var num = parseFloat(document. frmCalc. txtNumber. value);
if (!(isNaN(num))) {
prevCalc = num;
document. frmCalc. txtNumber. value = "";
calc = "Add";
}
}
//The following function is called when "Calculate" button is clicked.
//Note that this function is dependent on the value of global variable.
function calculate() {
var num = parseFloat(document. frmCalc. txtNumber. value);
if (!(isNaN(num))) {
if (calc == "Add"){
var total = previousCalc + num;
document. frmCalc. txtNumber. value = total;
}
}
function clear() {
document. frmCalc. txtNumber. value = "";
prevCalc = 0;
calc = "";
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:00
Assume that you have an array of integers named a. which of these code segments print the same results? int i = 1; while(i < a.length) { system.out.println(a[i]); i++; } int i; for (i = 0; i < a.length; i++) { system.out.println(a[i]); } for (int i : a) { system.out.println(i); } i and ii only ii and iii only i and iii only all three print the same results. all three print different results.
Answers: 3
question
Computers and Technology, 22.06.2019 11:30
To hide gridline when you display or print a worksheet
Answers: 1
question
Computers and Technology, 22.06.2019 18:10
Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter. write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 1
You know the right answer?
There are several syntax errors in the code that are preventing this calculator from working, find a...
Questions
question
Spanish, 27.04.2021 18:20
question
Spanish, 27.04.2021 18:20
question
Chemistry, 27.04.2021 18:20
Questions on the website: 13722367