Still understanding functions

I know that this is far off, but why isn’t this working? im trying to understand how function parameters work, so I decided to make something simple to see if I could pass in a number and have the function do an equation with the passed in value… I know that I don’t have a return set for the result. but it seems like the function isn’t even accepting the 5 as x… what am I doing wrong?

please help. thanks :sleepy:

function math(x) {
  
x * x;

};

math(5); 
console.log(math)

Hi @tuscannypolk !

You are actually not that far off.

Functions need to return something.
Throw the return in front of the expression here

return x * x

If you want to see the results in the console you need to include the full function call like this

console.log(math(5))
1 Like

I’m going to break down your code line by line to explain why it doesn’t work; refer to the comments I’m adding:

2 Likes

WOW ok thanks! I didn’t know Ide have to console log the function with the parameters and argument into the counsole.log!

Glad I wasn’t too far off, definitely makes me feel better lol.

Thanks a BUNCH! :+1:

1 Like

HUGE thanks. This is SUPER helpful. I get it now! :pray: