Questions

  1. Comma-separated strings are a common data format. How would you create an array of elements when given one?

  2. The \\b special character can define a word boundary, and \\B matches on a nonword boundary. Define a regular expression that will find all occurrences of the word “fun” in the string and replace them with “power”:

  3. “The fun of functions is that they are functional.”
  4. Create code to get today’s date, modify it by a week, and print out the new date.

  5. Given a number of 34.44, how would you round the number down? Round it up?

  6. Given a string like the following, use pattern match and replace to turn all punctuation into commas, and then load as an array and print out each value:

  7. var str = "apple.orange-strawberry,lemon-.lime";

Answers are provided in the appendix.

Get Learning JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.