re: JavaScript Quiz VIEW POST

VIEW FULL DISCUSSION
 

Without looking:

'1. null === undefined: ' + false;
'2. null == undefined: ' + true;
'3. 2+"4": ' + '24';
'4. 2-"3": ' + -1;
'5. ""+2: ' + '2';
'6. +"2": ' + 2;

I love these! I even have a codepen that's kind of like this

 

Right answers

Oh, yeah, I know my weird Javascript math 🎉

1 and 2 I know because of work since null and undefined can be a pain when testing.

3 is string concatination with 2 being made a string to make it magically work.

4 is making the string a number to make the math operator magically work.

5 is similar to 3 in that it's concatinating an (empty) string with a number that magically becomes a string.

6 is fun because + is the shorthand for type converting to an int.

code of conduct - report abuse