could you please review my code for loops test?
Hi @bedribulut
Congratulations! Everything is correct.
I see you have used the three traditional loops. When looping over an array it’s often easier to use the more modern for...of
loop.
For example in task 2 you could use for (const entry of phonebook) {
and replace phonebook[i]
with entry
in the loop body.
Have a nice day,
Michael
thank you so much @mikoMK
actually I completed the tasks with what I learnt in the module. I have not studied for modern loops detailedly therefore I have not known that there would be a modern way.
I appreciate for you informing me.
have a nice day too.
You’re welcome!
It seems we do introduce it in “Looping through a collection”:
And further down we mention it under “Which loop type should you use”:
That being said, there’s nothing wrong with using traditional loops.