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 13:30
In which phase does software coding and testing happen in the spiral model? the spiral model does not have a separate testing phase. both, software coding and testing occurs during the phase.
Answers: 3
question
Computers and Technology, 22.06.2019 22:20
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a.edit the sizes and other characteristics of photos that have been inserted. b.take a screenshot of an image and copy it to the clipboard for pasting. c.search for drawings or other images from a library of prepared pictures. d.make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
question
Computers and Technology, 23.06.2019 21:50
Description: write function lastfirst() that takes one argument—a list of strings of the format "lastname, firstname" —and returns a list consisting of two lists: (a) a list of all the last names (b) a list of all the first names
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
Mathematics, 08.10.2020 01:01
question
Social Studies, 08.10.2020 01:01
question
Chemistry, 08.10.2020 01:01
Questions on the website: 13722363