FAQ: Functions - Function Declarations

Funnliy enough found my answer straight away once I started searching for the right thing, slightly embarrassed thanks for your patience.

1 Like

I don’t get why we use console.log again when there is a console.log inside the function. And this code doesn’t actually ouput “Hello, world!” when I run it on the codecademy lesson.

Shouldn’t it be:

 greetWorld()
 
 function greetWorld() {
   console.log('Hello, World!');
 }

Or:

console.log(greetWorld());

function greetWorld() {
  return 'Hello, World!';
}

I completely agree with your second example, and cannot explain why the narrative is written the way it is, or why it hasn’t been corrected by now. It’s out of our hands.