GitbookIO/javascript

Ambiguous language in for/while loop sample code

asciimike opened this issue · 0 comments

For loop:

Create using a for-loop a variable named message which equals the concatenation of integers (1, 2, 3, ...) from 0 to 100.

The first time I did this, I assumed that it wanted number 0 to 100 (inclusive):

for (var i = 0; i <= 100; i++) {
    /* code */
}

Which has a <= sign so it would include 100, which was marked as incorrect, since the for loop uses <100, which would stop at 99. The words seem to conflict with what the code is actually producing.

While loop:

Create using a while-loop a variable named message which equals the concatenation of integers (1, 2, 3, ...) as long as its length (message.length) is inferior to 100.

I would use "less than 100" rather than "inferior to 100", since I feel like less than creates a link between the words and the operator (as we did earlier with ands and ors).

For both of these, I would also start replace "integers (1, 2, 3, ...)" with "integers (0, 1, 2, ...), since both of these examples start with 0, and the last one doesn't indicate one should start at 0 rather than at 1.

Overall, this is an awesome project and I hope to see more programming books written in the same style! Keep up the good work :)