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?
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:
letand when should we use
constto declare a variable?
NaN? What about
Infinity? (Hint: if you are stuck, try detecting the data type.)
Take turns working through these prompts:
favNumequal to your favorite number and check the data type.
stringNumconverting 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.
===to confirm that they are equal.
stringNum) or second and third variables (
parsedBackToNum) to confirm that they are NOT equal.