Debugging Flashcards

1
Q

example of syntax error

A
funtcion willNotWork( 
  console.log("Yuck");
}
// "function" keyword is misspelled and there's a missing parenthesis
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

example of a runtime error

A
function loopy() {
  while(true) {
    console.log("Hello, world!");
  }
}
// Calling loopy starts an infinite loop, which may crash your browser
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

semantic error

A
function calcAreaOfRect(w, h) {
  return w + h; // This should be w * h
}
let myRectArea = calcAreaOfRect(2, 3);
// Correct syntax and the program executes, but this gives the wrong answer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

JavaScript recognizes six primitive (immutable) data types:

A

Boolean, Null, Undefined, Number, String, and Symbol (new with ES6) and one type for mutable items: Object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Almost every value on its own in JavaScript evaluates to ____, except what are known as the “falsy” values:

A

true

false, 0, “” (an empty string), NaN, undefined, and null.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The order of arguments in the function ___

A

matters, and you may get incorrect output if you mix them up, type or order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Off by one errors___

A

crop up when you’re trying to target a specific index of a string or array (to slice or access a segment), or when looping over the indices of them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

uncover buggy behavior related to resetting, or failing to reset a variable.

A

Printing variable values with each cycle of your loop by using console.log()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Ways to get an infinite loop

A

One error is incrementing or decrementing a counter variable in the wrong direction from the terminal condition.

Another one is accidentally resetting a counter or index variable within the loop code, instead of incrementing or decrementing it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly