Function - no output

I am trying to run my sample Function statement in the mini quiz. It comes out correct but I can’t see any output on the console. Is this ok?

Hi @jgmorcilla
your function isn’t running unless it’s called.

3 Likes

Sometimes codecademy has instructions that don’t output anything… or sometimes even give errors (on purpose).

Like mirja_t said, you have to call the function for it to do anything, as functions are just little containers that contain code waiting to be executed.

Example:

function sayHello(){
  console.log("Hello, world!");
}

It simply makes a function called sayHello. Since functions are meant to be used over and over again, it makes sense that it won’t do anything unless you call it (kind of like you only call the plumber if you need help but they are still there).

To make it do something, call it like so (technically functions are declared before execution, so sometimes you can call them before they are declared, but that is considered bad practice so make sure to place the function call after you declare it):

sayHello(); //Will output "Hello, world!"

There there you have it!

1 Like