Loops, How to identify them
let books = ['Infinite Jest', 'Gravity's Rainbow', 'Bronze-Age Pervert', 'The Culture of Narcissism', 'The Ego and the Id']
let oneBook = {
title: 'Infinite Jest',
author: 'David Foster Wallace'
publisher: 'I dont know'
}
function loopThroughBooks(books) // the books you will be looping towards
for(let i = 0; i < 2; i++){ // adds one to i everytime the statement runs.
//statement
console.log(i)
}
}
loopThroughBook(books)
when you console.log this, it gives you a printed result of 0, 1 on your console. The for loop intializes, it assigns the value of 0 to the i, it asks itself if i < 2. if you were to
console.log(i < 2) // the console would print out true