Introduction to JavaScript (Multiple Choice Quiz)


#1

Hi guys, very new here. Just started with JavaScript courses.
Stumbled upon this question in the Pro Trial Quiz under
https://www.codecademy.com/learn/javascript track.

Which of the following statements returns false?

  • 'myName'.length > 2
  • 4/2 == 2
  • 3 *4<15
  • 'InputControl'.length < 4

First question, is ' ' acceptable vs " " for quoting strings in Javascript?
If yes, then choice no.4 would seem quite wrong.
However,
For choice no.2, isn't it supposed to be === right?

Thks for the help!


#2

Both the types of quotations are acceptable.

Agreed.

== and === are both acceptable in this example as you are checking for equality. There is a difference between them tho, I suggest you read this if you are wanting to know.


#3

To expand on equality,

==

will coerce the value on the right to match the type on the left, if possible.

1 == "1"   =>  true

since the value on the right can be coerced to a number type.

===

Does not rely upon coercion, and will return type mismatch error if the types are not identical.

==   =>  equality

===  =>  identity

#4

Wow, that is real fast!

Thanks for the fast reply @oscartbeamish, certainly boast my motivation to learn some coding by myself! Appreciated! :smile:


#5

Hi @mtf thanks for the explanation! Guess I have lots of reading to do! Just starting from ground zero.


#6

Just come across this note:

String: Any grouping of words or numbers surrounded by single quotes: ' ... ' or double quotes " ... ".

in track https://www.codecademy.com/learn/learn-javascript

It was not mentioned in track https://www.codecademy.com/learn/javascript (the older track)

Just want to mention this for those who are checking out the differences between two tracks, the side notes differ as well. :sweat_smile:


#9