Review and Pursue
Beginning in Part 2: JavaScript Fundamentals, each chapter of this book ends with a “Review and Pursue” section. In these sections, you’ll find questions regarding the material just covered and prompts for ways to expand your knowledge and experience on your own. If you have any problems with these sections, either in answering the questions or pursuing your own endeavors, turn to the book’s supporting forum (www.LarryUllman.com/forums/).
Review
- How do you declare a variable?
- What is variable scope?
- What are the rules for a variable’s name?
- What is the assignment operator?
- What simple types were introduced in this chapter?
- How can you use a single quotation mark within a string? A double quotation mark?
- What does the *= operator do? How about +=? (There are two answers to this last question.) And what about ++?
- What operator can cause bugs when used with a string and a number together?
- What does the toFixed() method do?
- What are some of the differences between Number objects and the Math object?
- What is an empty string?
- What does the charAt() method do? What does indexOf() do? How about lastIndexOf()? What are the arguments to the indexOf() and lastIndexOf() methods? What happens when you use negative numbers for the second argument to either method?
- What function should you use to pull a substring out of a string and how do you use it?
- What are the various ways you can perform concatenation with strings?
- What are escape sequences?
- What are some of the ways you can convert a string to a number?
Pursue
- Use a development tool such as Firebug to practice creating and manipulating variables.
- Look up some of JavaScript’s reserved words, if you have not already.
- If you’re curious, find out what “hoisting” is.
- Create another calculator, such as one that calculates the area of a shape (rectangle, triangle, circle, etc.).
- Look online (e.g., at https://developer.mozilla.org) to research all the Number and Math object properties and methods.
- Look online to learn more about the String object and its methods.
- Create another string manipulation example.
- Update the shopping example to add a shipping cost option, and then rework the JavaScript to properly add the shipping amount to the total.
- Test all of this chapter’s code in as many browsers and devices as you can to see the various results.