Section 4.8. Questions


4.8. 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.




Learning JavaScript
Learning JavaScript, 2nd Edition
ISBN: 0596521871
EAN: 2147483647
Year: 2006
Pages: 151

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net