# JavaScript basics - arrow notation with for loop

Here’s the prompt:
You have some starter code provided. It’s a blank function that defines the task of filling your car up with gas. You can see that the minion will let you know that it filled up the car with gas, but you need to tell it how much gas you want put into the tank.

Since the minion needs information from you to do its job, you need to define the parameter of gallons inside the parenthesis of the function. When you do that successfully, run the code and the minion will let you know when it completes the task.

Now change the argument value. It is currently 15. Change it to any other number and see how the behavior of the function changes when the argument does.

THE STARTER CODE:

const fillGasTank = () => {
console.log(`I filled the tank with \${gallons} of gas`)
}

fillGasTank(15)

THE CODE I WROTE:

const fillGasTank = (arrayOfGasToBuy) => {

``````for (const gallons of arrayOfGasToBuy) {
console.log(`I filled the tank with \${gallons} of gas`)
}
``````

}
fillGasTank([15])

It says that arrayOfGasToBuy isn’t iterable. How do you determine parameters?
Just starting out, and I’m so lost. Can someone identify what I don’t understand and explain it to me.

Integers cannot be iterated.

Not sure I follow the need of a loop for this problem.

Hi there Ryan,

I think you are getting caught up in the wording of the exercise. I know it says you are filling up the tank and that the minion will let you know “when it filled up the car with gas” but really, this exercise is just trying to show you what arguments and parameters are in Javascript.

The way the starter code is, the function `fillGasTank()` doesn’t have any parameters. But the function call `fillGasTank(15)` is passing it an argument (the integer 15). So, to make it work together, you need to modify the definition of the function to have a parameter.
Finally, we can look at the `console.log` inside the function and see they use the variable `gallons`. That’s a hint that the parameter you need define for the function should be called that way.

To emphasize, there is no need for you to implement any logic in the function. It’s not about filling up the tank until the minion says it’s full or anything like that.

Wow, thank you for explaining. I’m still a little unclear on understanding parameters, but I think that will come. This was really helpful!

2 Likes