subject
Computers and Technology, 31.05.2021 16:20 120175

For this activity, you will practice being both proactive and reactive to bugs. Both are necessary to get rid of errors in code. Proactive:

Log in to REPL. it and open your Calculator program that you built in Unit 5.
In the index. js file, type and finish the following block of code that validates the input to make sure both are numbers (not letters or symbols):
try{
if (isNaN(…) || isNaN(…)){
throw …
}
else{
document. getElementById("answer").innerHTML = num1 + num2;
}
}
catch(e){
document. getElementById("answer")…
}

(Note: The || symbol is used in JavaScript to mean or . You can find this key to the left of the Z key if you’re using a PC or directly above the Enter key if you’re using a Mac.)
Add the finished code above to the correct place in your add() function. Make sure to delete this line since we moved it into the try block:
document. getElementById("answer").innerHTML = num1 + num2;
Paste the same code into the subtract() , multiply() , and divide() functions, making the necessary changes. Be careful with your divide() function since you already have an extra if else statement checking for a division by 0 mistake. (Hint: Cut and paste the entire if else statement inside the else block of your try statement.)
Test your program by typing in letters or symbols instead of numbers. Make sure you get the appropriate error message. (Note: The function is not supposed to check whether the text field is empty, only whether it contains non-numbers.)
When you are finished, share the link to your webpage with your teacher by clicking on the share button and copying the link.
Reactive:
The following Python program should print the sum of all the even numbers from 0 to 10 (inclusive), but it has two bugs:

x = 0
sum = 0
while x < 10:
sum = sum + x
x = x + 1
print(sum)
Complete a trace table and then write a sentence or two explaining what the errors are and how to fix them. You can choose whether to do the trace table by hand or on the computer. Turn in your trace table and explanation to your teacher.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:20
Octothorpe is another name for what common computer keyboard symbol?
Answers: 1
question
Computers and Technology, 22.06.2019 22:30
Who needs to approve a change before it is initiated? (select two.) -change board -client or end user -ceo -personnel manager -project manager
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
Why is investing in a mutual fund less risky than investing in a particular company's stock? a. mutual funds only invest in blue-chip stocks. b. investments in mutual funds are more liquid. c. mutual funds hold a diversified portfolio of stocks. d. investments in mutual funds offer a higher rate of return.
Answers: 2
question
Computers and Technology, 23.06.2019 07:30
What key should you press and hold to select and open multiple files at one time? enter alt control esc
Answers: 1
You know the right answer?
For this activity, you will practice being both proactive and reactive to bugs. Both are necessary t...
Questions
question
English, 22.04.2021 09:40
question
Mathematics, 22.04.2021 09:40
question
Spanish, 22.04.2021 09:40
question
Mathematics, 22.04.2021 09:40
Questions on the website: 13722361