Chapter 5 Review

  1. How is a particular date and time actually stored in a Date object?
  2. Declare a variable named now that holds a reference to a Date object representing the current date and time.
  3. Declare a variable named final that holds a reference to a Date object representing 1:30pm on April 24, 2020.
  4. What are the three primitive wrapper types?
  5. Primitive variables do not have methods, yet we can invoke methods on primitive variables. What is the JavaScript engine doing in order to accomplish this?
  6. Suppose a variable named mean has the value 76.3245. Provide a statement that prints to the console the value in mean with only 1 digit after the decimal point.
  7. Suppose a variable named name has the value “Joe Block”. Provide a statement that prints to the console the number of characters in name.
  8. Provide a statement that prints to the console the last character of the String in the variable named str.
  9. What are the three methods used to create substrings from strings?
  10. Suppose a string named course has the value “CSCI-240”. Write a statement that uses one of the substring methods to stores in a variable named num the numeric part of the course (“240”).
  11. Write a statement that uses a string method to store in a variable named loc the index of the first instance of “S” in the string course.
  12. What type of value is returned from startsWith(), endsWith(), and includes()?
  13. What do trim(), trimLeft(), and trimRight() do?
  14. Write a fragment of code that uses a string iterator and a while loop to print to the console the characters in the string “hello”, one on each line.
  15. Write a single statement that uses the destructuring operator to print to the console the characters in the string “hello”, one on each line.
  16. What variable holds a reference to the Global object?
  17. Write a fragment of code that returns a random number between 1 and 20.

© 2020, Eric. All rights reserved.