Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT DATA / CHAPTER 02 / Learn / LESSON 03
Third class. You want each amount on its own line. for...of walks the values:
for (const amount of amounts) { console.log(amount); }
Each time, amount gets the next number. For beginners this is simpler than a classic index for.
Mini example:
for (const n of [12, 25]) { console.log(n); }
Common mistake: for (const amount in amounts) — in walks keys/indexes as strings, not the values.
for...of yields each element value.
DATA STANDBY
›