Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JavaSript Question 6 (1 point) If you use a short-circuit operator to combine tw

ID: 3910732 • Letter: J

Question

JavaSript

Question 6 (1 point)

If you use a short-circuit operator to combine two expressions

Question 6 options:

both expressions are always evaluated

the second expression is evaluated only if it can affect the result

the first expression is evaluated only if it can affect the result

the result of each expression is reversed

Question 7 (1 point)

In the following statement, which expression is evaluated first?
var truth = !A || B && (C || D)

Question 7 options:

!A

B && (C || D)

C || D

!A || B

Save

Question 8 (1 point)

The condition for a while loop is tested

Question 8 options:

before the statements in the loop are executed

after the statements in the loop are executed

before and after the statements in the loop are executed

before or after the statements in the loop are executed, depending on how the condition is coded

Save

Question 9 (1 point)

If you want the block of code in a loop to be executed at least once, you would normally use

Question 9 options:

a while loop

a for loop

a do-while loop

either A or C

Save

Question 10 (1 point)

When the code that follows is executed, a message is displayed if the value the user enters
var userEntry = (prompt("Enter cost:");
if (isNaN(userEntry) || userEntry > 500 ) {
     alert ("Message");
}

Question 10 options:

isn’t a number or the value in userEntry is more than 500

isn’t a number and the value in userEntry is more than 500

is a number or the value in userEntry is more than 500

is a number and the value in userEntry is more than 500

both expressions are always evaluated

the second expression is evaluated only if it can affect the result

the first expression is evaluated only if it can affect the result

the result of each expression is reversed

Question 7 (1 point)

In the following statement, which expression is evaluated first?
var truth = !A || B && (C || D)

Question 7 options:

!A

B && (C || D)

C || D

!A || B

Save

Question 8 (1 point)

The condition for a while loop is tested

Question 8 options:

before the statements in the loop are executed

after the statements in the loop are executed

before and after the statements in the loop are executed

before or after the statements in the loop are executed, depending on how the condition is coded

Save

Question 9 (1 point)

If you want the block of code in a loop to be executed at least once, you would normally use

Question 9 options:

a while loop

a for loop

a do-while loop

either A or C

Save

Question 10 (1 point)

When the code that follows is executed, a message is displayed if the value the user enters
var userEntry = (prompt("Enter cost:");
if (isNaN(userEntry) || userEntry > 500 ) {
     alert ("Message");
}

Question 10 options:

isn’t a number or the value in userEntry is more than 500

isn’t a number and the value in userEntry is more than 500

is a number or the value in userEntry is more than 500

is a number and the value in userEntry is more than 500

Explanation / Answer

(6) Whenever you'll use a short circuit operator, the second expression is evaluated only if it can affect the result. Say you need to calculate (x>3) && 0. Now no matter what the value of x>3 is, since 0 will always make sure that the total expression comes to be false due to short-circuiting, hence the value of 1st won't matter.

(7)Whenever java sees a && or a ||, the expression on the left-hand side is always evaluated first hence !A || B will be evaluated before C||D and within the expression !A ||B itself, !A will be evaluated first

(8) The conditions in a while loop are always tested BEFORE THE STATEMENTS IN THE LOOP ARE EXECUTED

(9) A DO WHILE LOOP runs at least once whereas a for and a while loop check the conditions before running

(10) Since an or operator is used hence if any of the two conditions are met ie if it's not a number or the number is >500, the alert message will pop up!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote