// Practice Set · JS Errors · guest

Guest practice: this set is not saved and does not count.

Question 1 of 5 from: JS Errors Intro

What does this log?

try {
  JSON.parse("{bad json}");
} catch (e) {
  console.log(e.name, e instanceof SyntaxError);
}
Question 2 of 5 from: JS Errors Intro

If a script has a syntax error on line 20, a console.log("Before") on line 1 never prints.

Question 3 of 5 from: JS Errors Silent

What does this log?

function average(list) {
  if (list.length === 0) {
    throw new RangeError("Cannot average an empty list");
  }
  let sum = 0;
  for (const n of list) sum += n;
  return sum / list.length;
}
try {
  console.log(average([90, 80]));
  console.log(average([]));
} catch (e) {
  console.log(e.name + ": " + e.message);
}
Question 4 of 5 from: JS Error Statements

A try...catch placed around a setTimeout call will catch an error thrown later inside the timer's callback.

Question 5 of 5 from: JS Error Object

What does this log?

function inner() {
  return null.x;
}
function outer() {
  return inner();
}
try {
  outer();
} catch (err) {
  console.log(typeof err.stack, err.name, err instanceof TypeError);
}
Ready to submit?

Click a question to go back and check it. After you submit, you will see the right answer and an explanation for every question. As a guest, nothing is saved.