Javascript section of Front End Developer

Lesson 10: What is JavaScript?
==============================
6. JavaScript Demo
------------------
Question 1: What happened when you ran that line of code in the JavaScript console? document.getElementsByTagName("h1")[0].style.color = "#ff0000";
Option 2: The heading changed to red
Question 2: What happens when you run the code from above in the JavaScript console and then click on the page?
Option 3: An image is added to the page

Lesson 11: Data Types & Variables
=================================
2. Numbers
----------
Question 1: -92, -4, -12, 4
Question 2: false, false, true, true

4. Quiz: First Expression
-------------------------
console.log(42/1*1+0);

6. String Concatenation
-----------------------
Question 1: What's the result with "hello" + "world"?
Option 2: "helloworld" (no space)
Question 2: What do you think will happen when you type "Hello + 5*10" into the JavaScript console?
Option 3: "Hello + 5*10" (just a string)
Question 3: What do you think will happen when you type "Hello" + 5*10 into the console?
Option 2: "Hello50"

7. Variables
------------
Question: Which of these are good variable names?
Option 2: var count = 1;
Option 3: var postLiked = false;

8. Quiz: Converting Temperatures
--------------------------------
var celsius = 12;
var fahrenheit = celsius*1.8+32;

console.log(fahrenheit);

9. String Index
---------------
Question: What character will be printed to the JavaScript console after running the following lines of code.
var quote = "Stay awhile and listen!";
console.log(quote[6]);
Option 2: w

10. Escaping Strings
--------------------
Question: Select the string that returns the following output: "The file located at "C:\\Desktop\My Documents\Roster\names.txt" contains the names on the roster."
Option 3: ... \"C:\\\\ ...

11. Comparing Strings
---------------------
Question: Enter each expression into the console. Check the ones that evaluate to true.
Option 2: "green" == "green"
Option 5: "green" > "blue"
Option 7: "green" > "Green"

12. Quiz: Favorite Food
-----------------------
console.log("Dumpling");

13. Quiz: String Equality for All
---------------------------------
var answer = "ALL Strings are CrEaTeD equal" == "ALL Strings are CrEaTeD equal";
console.log(answer);

14. Quiz: All Tied Up
---------------------
var joke = "Why couldn\'t the shoes go out and play?\nThey were all \"tied\" up!"
console.log(joke);

15. Yosa Buson
--------------
// declaration of variables must be first
var a = "Blowing from the west\n";
var b = "Fallen leaves gather\n";
var c = "In the east.";
var haiku = a+b+c;

console.log(haiku);

17. Quiz: Facebook Post
-----------------------
Question: string, string, string, boolean, number

18. Null, Undefined, and NaN
----------------------------
Question: What will be printed out?
var signedIn;
console.log(signedIn);
Option 1: undefined

19. Equality
------------
Question 1: What value do you think the result of "Hello" % 10 will be?
Option 5: NaN
Question 2: Check the expressions that evaluate to true.
Option 1: "3" > 1
Option 3: true >= 0
Option 4: 1 !== false
Option 6: 3 === 3

20. Quiz: Semicolons!
---------------------
var thingOne = "red";
var thingTwo = "blue";
console.log(thingOne +" "+ thingTwo);

21. Quiz: What's my Name?
-------------------------
var fullName = "Admin Tom"

22. Quiz: Out to Dinner
-----------------------
var bill = 10.25 + 3.99 + 7.15;
var tip = 0.15 * bill;
var total = bill + tip;

console.log(total);

23. Quiz: Mad Libs
------------------
var adjective1 = 'amazing';
var adjective2 = 'fun';
var adjective3 = 'entertaining';

var madLib = 'The Intro to JavaScript course is '+adjective1+'. James and Julia are so '+adjective2+'. I cannot wait to work through the rest of this '+adjective3+' content!';

24. Quiz: One Awesome Message
-----------------------------
var firstName="Tom";
var interest="courses.czweb.org";
var hobby="listen to music";
var awesomeMessage="Hi, my name is "+firstName+". I love "+interest+". In my spare time, I like to "+hobby+".";

console.log(awesomeMessage);

Lesson 12: Conditionals
=======================
2. Quiz: Flowcharts
-------------------
Question 1: What data type would best represent (Yes/No) if you have enough money to purchase the item?
Option 3: Boolean
Question 2: If you decide to storm the castle, what is the immediate resulting outcome?
Option 1: A dragon appears and attacks!

5. Else If Statements
---------------------
Question 1: What will be printed to the console if the following code is run?

var money = 100.50;
var price = 100.50;

if (money > price) {
console.log("You paid extra, here's your change.");
} else if (money === price) {
console.log("You paid the exact amount, have a nice day!");
} else {
console.log("That's not enough, you still owe me money.");
}
Option 2: "You paid the exact amount, have a nice day!"
Question 2: Looking at the following code, determine what medal Kendyll received.

var runner = "Kendyll";
var position = 2;
var medal;

if(position === 1) {
medal = "gold";
} else if(position === 2) {
medal = "silver";
} else if(position === 3) {
medal = "bronze";
} else {
medal = "pat on the back";
}

console.log(runner + " received a " + medal + " medal.");

Option 2: Kendyll received a silver medal.

6. Quiz: Even or Odd
--------------------
var number = 5;

if(number % 2 === 1) {
console.log("odd");
} else {
console.log("even");
}

7. Quiz: Musical Groups
-----------------------
var musicians = 1;

if (musicians < 1) {
console.log("not a group");
} else if (musicians === 1) {
console.log ("solo");
} else if (musicians === 2) {
console.log ("duet")
} else if (musicians === 3) {
console.log ("trio");
} else if (musicians === 4) {
console.log ("quartet");
} else {
console.log ("this is a large group");
}

8. Quiz: Murder Mystery
-----------------------
var room = "dining room";
var suspect = "Mr. Parkes";

var weapon = "";
var solved = false;

if (room==="ballroom" && suspect==="Mr. Kalehoff") {
weapon="poison";
solved=true;
} else if (room==="gallery" && suspect==="Ms. Van Cleve") {
weapon="trophy";
solved=true;
} else if (room==="billiards room" && suspect==="Mrs. Sparr") {
weapon="pool stick";
solved=true;
} else {
weapon="knife";
solved=true;
}

if (solved) {
console.log(suspect+" did it in the "+room+" with the "+weapon+"!");
}

10. Logical Operators
---------------------
Question 1: What value of [BLANK] would make the following expression evaluate to false. Notice the ! right at the beginning!
!([BLANK] === 4) && "STRing" === "STRing"
Option 2: 4
Question 2: Select the operator that would make the following expression evaluate to true.
3 < -10 [BLANK] "James" !== "james"
Option 2: ||
Question 3: Evaluate the following logical expressions. Check the ones that evaluate to true.
Option 1: true || false
Option 4: (13 > -7) || (false == 0)
Option 6: (3 != 6 % 3) && !(24 > 45) && (!false)

12. Quiz: Checking your Balance
-------------------------------
var balance = 325.00;
var checkBalance = true;
var isActive = false;

if (checkBalance === false) {
console.log("Thank you. Have a nice day!");
} else if (isActive && balance > 0) {
console.log("Your balance is $"+balance.toFixed(2)+".");
} else if (!isActive) {
console.log("Your account is no longer active.");
} else if (balance === 0) {
console.log("Your account is empty.");
} else {
console.log("Your balance is negative. Please contact bank.");
}

13. Quiz: Ice Cream
-------------------
var flavor = "strawberry";
var vessel = "cone";
var toppings = "cookies";

if ((flavor =="vanilla" || flavor =="chocolate") && (vessel =="cone" || vessel =="bowl") && (toppings =="sprinkles" || toppings =="peanuts")) {
console.log("I\'d like two scoops of "+flavor+" ice cream in a "+vessel+" with "+toppings+".");
}

14. Quiz: What do I wear?
-------------------------
var shirtWidth = 23;
var shirtLength = 30;
var shirtSleeve = 8.71;

if (shirtWidth >=18 && shirtWidth <20 && shirtLength >=28 && shirtLength <29 && shirtSleeve >=8.13 && shirtSleeve <8.38) {
console.log("S");
} else if (shirtWidth >=20 && shirtWidth <22 && shirtLength >=29 && shirtLength <30 && shirtSleeve >=8.38 && shirtSleeve <8.63) {
console.log("M");
} else if (shirtWidth >=22 && shirtWidth <24 && shirtLength >=30 && shirtLength <31 && shirtSleeve >=8.63 && shirtSleeve <8.88) {
console.log("L");
} else if (shirtWidth >=24 && shirtWidth <26 && shirtLength >=31 && shirtLength <33 && shirtSleeve >=8.88 && shirtSleeve <9.63) {
console.log("XL");
} else if (shirtWidth >=26 && shirtWidth <28 && shirtLength >=33 && shirtLength <34 && shirtSleeve >=9.63 && shirtSleeve <10.13) {
console.log("2XL");
} else if (shirtWidth >=28 && shirtLength >=34 && shirtSleeve >=10.13) {
console.log("3XL");
} else console.log("N/A");

16. Truthy and Falsy
--------------------
Question: Select the truthy values from the list of values.
Option 2: "null"
Option 3: -5

17. Ternary Operator
--------------------
Question: What will be printed to the console if the following code is run?
var adult = true;
var preorder = true;

console.log("It costs $" + (adult ? "40.00" : "20.00") + " to attend the concert. Pick up your tickets at the " + (preorder ? "will call" : "the gate") + ".");
Option 4: It costs $40.00 to attend the concert. Pick up your tickets at the will call.

18. Quiz: Navigating the Food Chain
-----------------------------------
var eatsPlants = false;
var eatsAnimals = true;

var category = eatsPlants ? (eatsAnimals ? "omnivore" : "herbivore") : (eatsAnimals ? "carnivore" : undefined);

console.log(category);

19. Switch Statement
--------------------
Question: What will be the result from the following switch statement?
Option 3: There are 28 days in this month.

20. Falling-through
-------------------
Question: If winner is equal to 3, then what will be output to the console?
Option 1: You've won a smartwatch and tickets to the circus.

21. Quiz: Back to School
------------------------
var salary;

switch (education) {
case "no high school diploma":
salary = 25636;
break;
case "a high school diploma":
salary = 35256;
break;
case "an Associate's degree":
salary=41496;
break;
case "a Bachelor's degree":
salary=59124;
break;
case "a Master's degree":
salary=69732;
break;
case "a Professional degree":
salary=89960;
break;
case "a doctoral degree":
salary=84396;
break;
}
console.log("In 2015, a person with "+education+" earned an average of $"+salary.toLocaleString("en-US")+"/year.");

Lesson 13: Loops
================
3. Parts of a While Loop
------------------------
Question 1: How many times will the while loop run?

var x = 10;
while (x <= 25) {
console.log('Printing out x = ' + x);
x = x + 2;
}
Option 3: 8
Question 2: Here's a while loop that is supposed to print out the values of x from 0 to 5, but there's a bug. What is missing?

while (x < 6) {
console.log('Printing out x = ' + x);
}
Option 1: x never increments
Option 3: x is never assigned a start value

4. Quiz: JuliaJames
-------------------
var x = 1;

while (x<=20) {
if (x%15===0) {
console.log("JuliaJames");
} else if (x%5===0) {
console.log("James");
} else if (x%3===0) {
console.log("Julia");
} else console.log(x);
x+=1;
}

5. Quiz: 99 Bottles of Juice
----------------------------
var low;
var num = 99;

while (num>=1) {
low=num-1;
if (!(num===1 || num===2)){
console.log(num+" bottles of juice on the wall! "+num+" bottles of juice! Take one down, pass it around... "+low+" bottles of juice on the wall!");
} else if (num===2){
console.log(num+" bottles of juice on the wall! "+num+" bottles of juice! Take one down, pass it around... "+low+" bottle of juice on the wall!");
} else console.log(num+" bottle of juice on the wall! "+num+" bottle of juice! Take one down, pass it around... "+low+" bottles of juice on the wall!");
num--;
}

6. Quiz: Countdown, Liftoff!
----------------------------
sec=60;

while (sec>=0) {
if (sec===50 || sec===31 || sec===16 || sec===10 || sec===6 || sec===0){
switch (sec){
case 50:
console.log("Orbiter transfers from ground to internal power");
break;
case 31:
console.log("Ground launch sequencer is go for auto sequence start");
break;
case 16:
console.log("Activate launch pad sound suppression system");
break;
case 10:
console.log("Activate main engine hydrogen burnoff system");
break;
case 6:
console.log("Main engine start");
break;
case 0:
console.log("Solid rocket booster ignition and liftoff!");
break;
}
} else console.log("T-"+sec+" seconds");
sec--;
}

9. Nested Loops
---------------
Question: What will this loop print out?

for (var i = 0; i <= 6; i = i + 2) {
console.log(i);
}
Option: 0 2 4 6

11. Quiz: Changing the Loop
---------------------------
for (var x=9;x>=1;x--){
console.log("hello " + x);
}

12. Quiz: Fix the Error
-----------------------
for (var x=5;x < 10; x++) {
console.log(x);
}

13. Quiz: Fix the Error
-----------------------
for (var k = 0; k < 200; k++) {
console.log(k);
}

14. Quiz: Factorials!
---------------------
var solution=1;
var fact=12;

for(fact;fact>0;fact--){
solution*=fact;
}
console.log(solution);

15. Quiz: Find my Seat
----------------------
for (var row=0;row<26;row++){
for (var seat=0;seat<100;seat++) {
console.log(row+"-"+seat);
}
}

Lesson 14: Functions
====================
3. Declaring Functions
----------------------
Question 1: Use the following function to answer this question.

function findAverage(x, y) {
var answer = (x + y) / 2;
return answer;
}

var avg = findAverage(5, 9);

What value will be stored in the variable avg?
Option 3: 7
Question 2:
function findAverage(x, y) {
var answer = (x + y) / 2;
return answer;
}

var avg = findAverage(5, 9);

Are x and y parameters or arguments for this function?
Option 1: Parameters

5. Quiz: Laugh if Off 1
-----------------------
function laugh(){
return "hahahahahahahahahaha!";
}

console.log(laugh());

6. Quiz: Laugh it Off 2
-----------------------
function laugh(num){
var ha="";
for(num;num>0;num--){
ha+="ha";
}
ha+="!";
return ha;
}

console.log(laugh(3));

7. Return Values
----------------
Question 1: What does this function "return"?

function sleep() {
console.log("I'm sleepy!");
return "zzz";
return "snore";
}

sleep();
Option 2: "zzz"
Question 2: What number will be "printed" (to the JavaScript console)?

function square(x) {
return x * x;
}

function subtractFour(x) {
return square(x) - 4;
}

console.log(subtractFour(5));
Option 3: 21
Question 3: What do you think will happen with the following code?

function test() {
return 1;
return 2;
}

test();
Option 1: 1 will be returned

8. Using Return Values
----------------------
Question: Try predicting what will be printed in the console.log statement below. Then, check your prediction by pasting the code into the JavaScript console. Functions can be tricky, so try figuring it out before running the code!

function addTen(x) {
return x + 10;
}

function divideByThree(y) {
return y / 3;
}

var result = addTen(2);
console.log(divideByThree(result));
Option: 4: 4

10. Scope Example
-----------------
Question 1: Which of these variables a, b, c, or d, is defined in the global scope?

var a = 1;
function x() {
var b = 2;
function y() {
var c = 3;
function z() {
var d = 4;
}
z();
}
y();
}

x();
Option 1: a
Question 2: Where can you print out the value of variable c without resulting in an error?

var a = 1;
function x() {
var b = 2;
function y() {
var c = 3;
function z() {
var d = 4;
}
z();
}
y();
}

x();
Option 3: anywhere inside function y()
Option 4: anywhere inside function z()

11. Shadowing
-------------
Question 1: Without pasting into your console, what do you think this code will print out?

var x = 1;

function addTwo() {
x = x + 2;
}

addTwo();
x = x + 1;
console.log(x);
Option 4: 4
Question 2: Without pasting into your console, what do you think this code will print out?

var x = 1;

function addTwo() {
var x = x + 2;
}

addTwo();
x = x + 1;
console.log(x);
Option 2: 2

14. Hoisting
------------
Question 1: What value will be printed to the console?

sayHi("Julia");

function sayHi(name) {
console.log(greeting + " " + name);
var greeting;
}
Option 4: undefined Julia
Question 2: What value will be printed to the console?

sayHi("Julia");

function sayHi(name) {
console.log(greeting + " " + name);
var greeting = "Hello";
}
Option 4: undefined Julia
Question 3: What value will be printed to the console?

function sayHi(name) {
var greeting = "Hello";
console.log(greeting + " " + name);
}

sayHi("Julia");
Option 9: Hello Julia

16. Quiz: Build a Triangle
--------------------------
function makeLine(length) {
var line = "";
for (var j = 1; j <= length; j++) {
line += "* ";
}
return line + "\n";
}

// your code goes here. Make sure you call makeLine() in your own code.
function buildTriangle(row){
var line="";
for (var i=1;i<=row;i++){
line+=makeLine(i);
}
return line;
}

// test your code by uncommenting the following line
console.log(buildTriangle(10));

20. Quiz: Laugh
---------------
var laugh = function(times){
var hah="";
for(times;times>0;times--){
hah+="ha";
}
return hah+"!";
}

console.log(laugh(10));

21. Cry
-------
var cry = function boohoo(){
return "boohoo!";
};
console.log(cry);

22. Quiz: Inline
----------------
function emotions(myString, myFunc) {
console.log("I am " + myString + ", " + myFunc(2));
}

emotions("happy",function(times){
var hah="";
for(times;times>0;times--){
hah+="ha";
}
return hah+"!";
});

Lesson 15: Arrays
=================
3. Creating an Array
--------------------
Question: Select the valid arrays from the list below.
Option 2: [33, 91, 13, 9, 23]
Option 3: [null, "", undefined, []]
Option 4: [3.14, "pi", 3, 1, 4, "Yum, I like pie!"]

5. Array Index
--------------
Question 1: Take a look at the following donuts array.

var donuts = ["glazed", "chocolate frosted", "Boston cream", "powdered", "sprinkled", "maple", "coconut", "jelly"];

What line of code would you use to select the "coconut" donut from the donuts array?
Option 3: donuts[6]
Question 2: We’ve decided to replace some of donuts in the donuts array.

var donuts = ["glazed", "chocolate frosted", "boston cream", "powdered", "sprinkled", "maple", "coconut", "jelly"];

donuts[2] = "cinnamon twist";
donuts[4] = "salted caramel";
donuts[5] = "shortcake eclair";

What does the donuts array look like after the following changes?
Option 3: ["glazed", "chocolate frosted", "cinnamon twist", "powdered", "salted caramel", "shortcake eclair", "coconut", "jelly"]

6. Quiz: UdaciFamily
--------------------
var udaciFamily = ["Julia", "James", "Tom"];
console.log(udaciFamily);

7. Quiz: Building the Crew
--------------------------
var captain = "Mal";
var second = "Zoe";
var pilot = "Wash";
var companion = "Inara";
var mercenary = "Jayne";
var mechanic = "Kaylee";

// your code goes here
var crew = [captain,second,pilot,companion,mercenary, mechanic];
console.log(crew);

8. Quiz: The Price is Right
---------------------------
var prices = [1.23, 48.11, 90.11, 8.50, 9.99, 1.00, 1.10, 67.00];

prices[0]=1;
prices[2]=2;
prices[6]=3;
console.log(prices);

10. Length
----------
Question: What is the length of the following inventory array?

var inventory = [
["gold pieces", 25],
["belt", 4],
["ring", 1],
["shoes", 2]
];
Option 2: 4

12. Pop
-------
Question: We’ve decided to replace some of the donuts in the donuts array.

var donuts = ["glazed", "strawberry frosted", "powdered", "Boston creme"];

donuts.pop();
donuts.pop();
donuts.pop();
donuts.push("maple walnut");
donuts.pop();
donuts.push("sprinkled");

What does the donuts array look like after the following changes?
Option: ["glazed", "sprinkled"]

13. Splice
----------
Question: We’ve decided to replace some of the donuts in the donuts array.

var donuts = ["cookies", "cinnamon sugar", "creme de leche"];

donuts.splice(-2, 0, "chocolate frosted", "glazed");

What does the donuts array look like after the following changes?
Option 1: ["cookies", "chocolate frosted", "glazed", "cinnamon sugar", "creme de leche"]

14. Quiz: Colors of the Rainbow
-------------------------------
var rainbow = ["Red", "Orange", "Blackberry", "Blue"];

rainbow.splice(2,1,"Yellow","Green");
rainbow.splice(-0,0,"Purple")

15. Quiz: Quidditch Cup
-----------------------
function hasEnoughPlayers(team){
if (team.length<7) return false;
else return true;
}

var team = ["Oliver Wood", "Angelina Johnson", "Katie Bell", "Alicia Spinnet", "George Weasley", "Fred Weasley", "Harry Potter"];
console.log(hasEnoughPlayers(team));

16. Quiz: Joining the Crew
--------------------------
var captain = "Mal";
var second = "Zoe";
var pilot = "Wash";
var companion = "Inara";
var mercenary = "Jayne";
var mechanic = "Kaylee";

var crew = [captain, second, pilot, companion, mercenary, mechanic];

var doctor = "Simon";
var sister = "River";
var shepherd = "Book";

crew.push(doctor,sister,shepherd);

17. Quiz: Checking out the Docs
-------------------------------
Question 1: Use the MDN Documentation to determine which of these methods would be best for reversing elements in this array:

var reverseMe = ["h", "e", "l", "l", "o"];
Option 3: reverse()
Question 2: What would be the best array method to sort the elements in this array:

var sortMe = [2, 1, 10, 7, 6];
Option 4: sort()
Question 3: Consider the following array, removeFirstElement:

var removeFirstElement = ["a", "b", "c"];

Let's say that you want to modify (i.e., mutate) removeFirstElement by removing the first element within it. Which method(s) could you use?
Option 3: shift()
Option 5: splice()
Question 4: What method would be best for changing this array into a string?

var turnMeIntoAString = ["U", "d", "a", "c", "i", "t", "y"];
Option 1: join()

20. Quiz: Another type of Loop
------------------------------
var test = [12, 929, 11, 3, 199, 1000, 7, 1, 24, 37, 4,
19, 300, 3775, 299, 36, 209, 148, 169, 299,
6, 109, 20, 58, 139, 59, 3, 1, 139
];

test.forEach(function(element,index){
if(element%3===0){
test[index]=element+100;
}
});
console.log(test);

22. Quiz: I Got Bills
---------------------
var bills = [50.23, 19.12, 34.01,
100.11, 12.15, 9.90, 29.11, 12.99,
10.00, 99.22, 102.20, 100.10, 6.77, 2.22
];

var totals = bills.map(function(bill){
bill*=1.15;
bill=bill.toFixed(2);
bill=Number(bill);
return bill;
});
console.log(totals);

25. Quiz: Nested Numbers
------------------------
var numbers = [
[243, 12, 23, 12, 45, 45, 78, 66, 223, 3],
[34, 2, 1, 553, 23, 4, 66, 23, 4, 55],
[67, 56, 45, 553, 44, 55, 5, 428, 452, 3],
[12, 31, 55, 445, 79, 44, 674, 224, 4, 21],
[4, 2, 3, 52, 13, 51, 44, 1, 67, 5],
[5, 65, 4, 5, 5, 6, 5, 43, 23, 4424],
[74, 532, 6, 7, 35, 17, 89, 43, 43, 66],
[53, 6, 89, 10, 23, 52, 111, 44, 109, 80],
[67, 6, 53, 537, 2, 168, 16, 2, 1, 8],
[76, 7, 9, 6, 3, 73, 77, 100, 56, 100]
];

// your code goes here

for (var row = 0; row < numbers.length; row++) {
for (var column = 0; column < numbers[row].length; column++) {
if (numbers[row][column]%2===0) {numbers[row][column]='even';}
else {numbers[row][column]='odd';}
console.log(numbers[row][column]);
}
}

Lesson 16: Objects
==================
3. Quiz: Umbrella
-----------------
var umbrella = {
color: "pink",
isOpen: true,
open: function() {
if (umbrella.isOpen === true) {
return "The umbrella is already opened!";
} else {
umbrella.isOpen = true;
return "Julia opens the umbrella!";
}
},
close: function(){
if (umbrella.isOpen === false) {
return "The umbrella is already closed!";
} else {
umbrella.isOpen = false;
return "Julia closes the umbrella!";
}
}
};

6. Naming Conventions
---------------------
Question 1: Given the following user object, what would you use to print the value of the email property?

var user = {
email: "user@example.com",
firstName: "first",
lastName: "last"
};
Option 3: console.log(user.email);
Option 4: console.log(user["email"]);

Question 2: Select the piece of code that creates an object that describes a red Honda Civic:
Option 1: var car = { manufacturer: "honda", model: "civic", class: "compact", color: "red" };
Option 3: var car = { color: "red" , manufacturer: "honda", model: "civic", class: "compact" };

8. Quiz: Menu Items
-------------------
var breakfast = {
name: "The Lumberjack",
price: 9.95,
ingredients: ["eggs","sausage","toast","hashbrowns","pancakes"]
}

9. Quiz: Bank Accounts 1
------------------------
var savingsAccount = {
balance: 1000,
interestRatePercent: 1,
deposit: function addMoney(amount) {
if (amount > 0) {
savingsAccount.balance += amount;
}
},
withdraw: function removeMoney(amount) {
var verifyBalance = savingsAccount.balance - amount;
if (amount > 0 && verifyBalance >= 0) {
savingsAccount.balance -= amount;
}
},
printAccountSummary: function(){
return "Welcome!\nYour balance is currently $"+savingsAccount.balance+" and your interest rate is "+savingsAccount.interestRatePercent+"%.";
}
};

console.log(savingsAccount.printAccountSummary());

10. Bank Accounts 2
-------------------
Question: Which of the following are valid ways to access properties and call methods from the savingsAccount object?
Option 1: savingsAccount.balance;
Option 3: savingsAccount["balance"];
Option 7: savingsAccount.withdraw(50);

11. Quiz: Facebook Friends
--------------------------
var facebookProfile = {
name: "Tom",
friends: 3,
messages: ["bla","blah"],
postMessage: function(message){
facebookProfile.messages.push(message);
},
deleteMessage: function(index){
facebookProfile.messages.splice(index,1);
},
addFriend: function(){
facebookProfile.friends+=1;
},
removeFriend: function(){
facebookProfile.friends-=1;
}
}

12. Quiz: Donuts Revisited
--------------------------
var donuts = [
{ type: "Jelly", cost: 1.22 },
{ type: "Chocolate", cost: 2.45 },
{ type: "Cider", cost: 1.59 },
{ type: "Boston Cream", cost: 5.99 }
];

donuts.forEach(function(element,index){console.log(element.type+" donuts cost $"+element.cost+" each");});