FOR LOOPS for (inital expression; condition; increment) { statements } use (i)for index for (let i = 10; i >= 1; i--) { if (i % 2 !== 2) console.log(i) } FOR IN LOOPS const device = { brand: 'Acer', model: 'TMP12-322', specs: { ram: 8, rom: 256 } } for (key in device.specs) { console.log(key, device.specs[key]) } // LOOP CONTROL for (let i = 1; i <= 10; i++) { if (i == 5) // the counting will stop less than 5 break; console.log(i) }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter