tracks

Codecademy

Ajax-loader-large-white
6/23
Review of Functions in JavaScript
Parameters are local to the function

Each parameter of a function is effectively a variable. As we saw in the previous lesson, it has a name that we can use inside the function to refer to the value that was supplied by the call to the function.

Once the function has been called, is that name available outside the function? To test this, first run the code as-is. You should see ReferenceError: w is not defined. What that means is that the name w was set to the value 2 inside the function when it was called, but was never defined outside of the function.

In fact, if you uncomment the first line, you will see that the variable w that exists outside of the function isn't affected by the argument of the function having the same name! The two are entirely different variables.

Instructions

Uncomment the first line and run the code again.

?
Stuck? Get a hint! Hint

All you need to do is remove the // from line 1, so it looks like this:

var w = 15;
script.js

Sign in