- What does a for loop do
- Syntax
for(...){...}
- What are the different parts of the for loop header
- How to iterate over an array with a for loop
- What is the increment/decrement operator
i++
/i--
The following topics are out of scope because they are covered by another concept exercise.
- Other loops like
while
- Other possibilities of iterating over an array
break
andcontinue
are only mentioned in the about.md file here because they will be more in focus in thewhile
exercise
The Concepts this exercise unlocks are:
for-loops
increment-decrement
arrays
because they are used to iterate over them in the exercisecomparison
for writing the condition in the loop headerconditionals
because they introduced the student to the concept of conditional execution
This exercise could benefit from the following rules in the analyzer:
For all tasks check that the student actually used a for loop.
-
totalBirdCount
- Verify that the condition is written with
< x.length
instead of<= y.length -1
. - Check whether a shorthand assignment
+=
was used to increase the sum (non-essential feedback). - Verify the total was properly initialized with
0
instead of e.g.null
- Verify the increment operator was used in loop header step
- Verify that the condition is written with
-
birdsInWeek
- Verify a helper variable was used instead of duplicating the calculation in the initialization and condition of the loop
- Other checks should be the same as for
totalBirdCount
-
fixBirdCountLog
- Check whether a shorthand assignment
+=
was used to increase the loop counter (non-essential feedback) - Check whether the increment operator was used in the loop body
- Check whether a shorthand assignment
The exercise is inspired by Bird Watcher Exercise in the C# track but the original exercise included more concepts and subsequently also tasks that cover all of these concepts. Since the exercise for the JavaScript track should be focussed on the for loop, the tasks where reduced and changed accordingly.