var books = ["JavaScript: The Good Parts", "Eloquent JS", "You Don't Know JS"];
for (var i = 0; i < books.length; i++) {
var book = books[i];
console.log(book);
}
// JavaScript: The Good Parts
// Eloquent JS
// You Don't Know JS
while ( /* Boolean expression */ ) {
Execute code
}
var total = 0;
var flip = Math.random();
while (flip > 0.5) {
total++;
flip = Math.random();
}
console.log("Number of consecutive times heads came up: " + total);
var person = {
firstName: "Homer",
middleName: "Jay",
lastName: "Simpson",
};
for (var key in person) {
console.log(key);
}
var person = {
firstName: "Homer",
middleName: "Jay",
lastName: "Simpson",
};
for (var key in person) {
console.log(person[key]);
}
var person = {
firstName: "Homer",
middleName: "Jay",
lastName: "Simpson",
};
for (var key in person) {
console.log(key);
}
var person = {
firstName: "Homer",
middleName: "Jay",
lastName: "Simpson",
};
for (var key in person) {
console.log(person[key]);
}
using a while loop,
log out 99 bottles of beer
using a for-in loop,
log out all the values in numbersObj squared
var numbersObj = {
numberOne: 2,
numberTwo: 4,
numberThree: 20,
numberFour: -7
}