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, 22.06.2019 17:00
What allows you to create a wireless connection among your smart devices
Answers: 2
question
Computers and Technology, 22.06.2019 17:30
Where would you click to edit the chart data?
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
question
Computers and Technology, 24.06.2019 15:50
Andy would like to create a bulleted list. how should he do this? andy should click on the bullet icon or select the bullet option from the menu and then type the list. andy should press the shift key and the 8 key at the beginning of each line of text. andy should type the text and then click on the bullet command. andy should press return and the bullets will automatically
Answers: 2
You know the right answer?
There are several syntax errors in the code that are preventing this calculator from working, find a...
Questions
question
Biology, 12.11.2020 02:40
question
Mathematics, 12.11.2020 02:40
question
Mathematics, 12.11.2020 02:40
question
English, 12.11.2020 02:40
question
Mathematics, 12.11.2020 02:40
question
Computers and Technology, 12.11.2020 02:40
question
English, 12.11.2020 02:40
Questions on the website: 13722363