Goal: Discuss and apply these JavaScript concepts with your pair:
Reminder: Use the browser DevTools console to try out your JS code! If you need a review, read the instructions on how to use and pair program with the DevTools console in this lesson.
Work through each section of this practice lesson, switching who's driving and who's observing between each prompt.
Use MDN documentation to learn about the remainder operator %
, also known as "modulo":
Make sure everyone understands what the remainder operator does, then work through these questions:
%
operator? How is the action it performs different from simply dividing?console.log()
do?Find the remainder of the following expressions by diving the two operands:
Find the reference page on MDN for the String.prototype.trim()
method. Read through the description and examples. Use the built-in console to try out this string method.
Switch who's driving and observing for this next prompt. Find the reference page on MDN for the String.prototype.replace()
method. Read through the description and examples. Note — ignore the references to regex; we'll learn about regex in coming weeks. Use the built-in console to try out this string method.
Take turns answering these questions:
let
and when should we use const
to declare a variable?undefined
?NaN
? What about Infinity
? (Hint: if you are stuck, try detecting the data type.)Take turns working through these prompts:
favNum
equal to your favorite number and check the data type.stringNum
converting the previous variable to a string. Check the data type again.parsedBackToNum
, converting this string variable back to a number. Check the data type one more time.favNum
and parsedBackToNum
) using ===
to confirm that they are equal.favNum
and stringNum
) or second and third variables (stringNum
and parsedBackToNum
) to confirm that they are NOT equal.