APPENDIX: EXERCISE HINTS
The hints below might help when you are stuck with one of the exercises in this book. They don’t give away the entire solution, but rather try to help you find it yourself.
Chapter 2: Program Structure
Looping a Triangle
You can start with a program that prints out the numbers 1 to 7, which you can derive by making a few modifications to the even number printing example given earlier in the chapter, where the for loop was introduced.
Now consider the equivalence between numbers and strings of hash characters. You can go from 1 to 2 by adding 1 (+= 1). You can go from “#” to “##” by adding a character (+= “#”). Thus, your solution can closely follow the number-printing program.
FizzBuzz
Going over the numbers is clearly ...
Get Eloquent JavaScript, 4th Edition 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.