Apply your functions mental model

I'm sure you know the drill by now. Let's burn some cognitive effort and work on our functions mental model.

1.

What will the following code output, and why?

  • a) "Hello, world!" and undefined
  • b) "Hello, world!" and the function definition
  • c) Error
  • d) undefined and undefined

##2.

What does the following code output?

  • a) 8
  • b) undefined
  • c) Error
  • d) NaN

In the code above, what term would we give for the operation argument? And what type of function is calculate ?

3.

What does the code output?

4.

What is console logged?

  • a) Hello, Alice!
  • b) Error
  • c) undefined
  • d) Hello, !

How can we call the add method with arguments 1 and 2 without accessing the object first?

Great work! Your mental model is growing 🌳. Let's get some more practice in.