Sasha D.

asked • 07/31/22

Compare userNumber with compareNumber and display 'Numbers are not equal' if the numbers are different. Then, display 'Variables are identical' if the variables are identical (strictly equal).

Code provided to complete the assignment:

let compareNumber = 3; // Code will be tested with: 3, 8, 42

let userNumber = '3'; // Code will be tested with: '3', 8, 'Hi'


Code I have so far:

if (compareNumber === userNumber){

console.log("Variables are identical");

}

else{

if (compareNumber == userNumber){

}

console.log("Numbers are not equal");

}


Results:

Testing log when compareNumber = 3 and userNumber = "3"

Yours and expected differ. See highlights below.

Yours

Numbers are not equal

Expected

Expected no output


Testing log when compareNumber = 8 and userNumber = 8

Yours

Variables are identical



Testing log when compareNumber = 42 and userNumber = "Hi"

Yours

Numbers are not equal


2 Answers By Expert Tutors

By:

Rize S. answered • 03/23/23

Tutor
New to Wyzant

Master's in MISM, 25 yrs Exp: HTML Expert

Marisa S. answered • 08/17/22

Tutor
New to Wyzant

Math and Technology Tutor

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.