Whats the point of a parameter?


#1

var orangeCost = function (price) {
console.log(price * 5);
};

orangeCost(5)

This code went through for me on lesson 6, the one about D.R.Y
I understand the whole point about using a reusable function and plugging in new info to it and getting a different result. I just have no idea how it does it.
When I put orangeCost(5), is the (5) after the function being called, the plug in info
that (price) is? Is (price) something that needs defining? And if so, how does simply typing it out after the function tell the computer that this is the definition?? Im so freaking CONFUSED. Maybe Im just overthinking it... Please help me understand how the computer is thinking during this equation.


#2

Yes that is pretty much it.
By using

... function(parameterName){...};

you declared a local variable parameter name just like you'd have done by using var parameterName inside of the function. And by passing an argument, some sort of value or information, to the function by using functionName(value)
this value gets assigned to the parameter. First argument to first parameter, second argument to second parameter and so on. So yes in this case the 5 in orangeCost(5) is the new value for the price in ... function(price).