×
Answer the following questions:
throw
keyword do?finally
keyword do?TypeError
and ReferenceError
?exception
?Explain what type of error will be thrown, why the error is occuring, and how to fix it:
1.
person;
2.
let data = {}; data.displayInfo();
3.
let data = {};
data.displayInfo.foo = "bar";
4.
function data(){ let thing = "foo"; } data(); thing;
Fix the broken code and explain what was wrong:
1.
for(let i=0; i > 5; i++){ console.log(i); }
2.
function addIfEven(num){ if(num % 2 = 0){ return num + 5; } return num; }
3.
function loopToFive(){ for(let i=0, i < 5, i++){ console.log(i); } }
4.
function displayEvenNumbers(){ let numbers = [1,2,3,4,5,6,7,8]; let evenNumbers = []; for(let i=0; i<numbers.length-1; i++;){ if(numbers % 2 = 0); { evenNumbers.push(i); } return evenNumbers; } } displayEvenNumbers(); // should return [2,4,6,8] // HINT - eight things need to be changed here for this to work! // Start by fixing the syntax errors and then run the function to see what your output is.
You can find solutions to the exercises here
When you're ready, move on to Nested Objects