Apply for the next session

Introduction

OK. So, there are more ways to iterate over things…

Recap

MDN: array.forEach()  (method)

Array.prototype.forEach() Function signature

JavaScript

someArray.forEach( function(currentItem, currentIndex, fullArray) {
	// do things
});

Array.prototype.forEach()

JavaScript

const apples = ["McIntosh", "Granny Smith", "Fuji", "Red Delicious", "Honey Crisp"];

apples.forEach( function(currentApple, appleIndex, fullApplesArray) {

	console.log('→ ', currentApple, appleIndex, fullApplesArray);

});

Live examples

See the Pen HTML cheatsheet 1 / display types by perpetual.education (@perpetual-education) on CodePen.

Do what while what?

MDN: while statement (loop)

MDN: do…while statement (loop)

Let’s do these before the for loop – because they are simple… but have more to consider in a way… and the for loop kinda encapsulates it all.

for statement

MDN: for statement (loop)

Break and Continue

for…in & for…of

MDN: for…in (loop)

MDN: for…of (loop)

Apply for the next session