exam questions

Exam 70-480 All Questions

View all questions & answers for the 70-480 exam

Exam 70-480 topic 1 question 23 discussion

Actual exam question from Microsoft's 70-480
Question #: 23
Topic #: 1
[All 70-480 Questions]

You need to test the value of the following variable in JavaScript. var length = "75";
A block of code must execute if the length equals 75 regardless of the data type.
You need to use the statement that meets this requirement.
Which lines of code should you use? (Each correct answer presents a complete solution. Choose two.)

  • A. if (length = = = 75)
  • B. if (length = = 75)
  • C. if (length! = 75)
  • D. if (length = = "75")
Show Suggested Answer Hide Answer
Suggested Answer: BD 🗳️
When comparison is made using double-equals operator (==), it will check the values of variable and convert them to a common type and returns true if both are equals. So comparing number with string having the same value will return true.
Examples:
examples:
console.log(23 == "23"); // true
console.log(1 == true); // true
Incorrect Answers:
not = = =: This is "strict" or "identical" equality.
Reference: JavaScript Triple Equals Operator vs Double Equals Operator ( = = = vs = = )

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
superhands
5 years, 1 month ago
technically none of the options are correct due to the fact that spaces in-between the equal signs will not work in the browser. i guess the intention is to just pretend the spaces are not there
upvoted 1 times
...
JMz123
5 years, 7 months ago
Wow. Most (all?) programming languages do not allow spaces in '==' or '===' or '!='. In addition, best practice is to leave a space around the operators. To wit, if ( 77 == value )
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago