Basic JavaScript - Passing Values to Functions with Arguments

Tell us what’s happening:
Describe your issue in detail here.
there is an unexpected error before when i type out the word function.

Your code so far

function 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Passing Values to Functions with Arguments

Link to the challenge:

You mean this:

SyntaxError: unknown: Unexpected token (2:0)

  1 | function
> 2 |
    | ^

Yeah, the IDE is trying to run your program as you type. That is a feature. Personally, I find it kind of annoying, but it is fairly common. It will keep giving you an error until what you type is valid JS.

It sees the keyword “function” and says, “wait, that is not valid JS all by itself”. It is expecting you to finish that statement.

If I type:

console.log('hey'

It will give me an error:

SyntaxError: unknown: Unexpected token, expected "," (1:17)

> 1 | console.log('hey'
    |                  ^

because that is not valid JS. If I finish it by adding a “)” at the end, it is now valid JS and will run.

Just keep typing until you finish your thought and then see if you have an error.

Type this out:

function foo() { console.log('bar') }
foo()

but pause after every character. If what you have there is valid JS, it won’t throw an error. If it isn’t, it will.

1 Like