JavaScript Function Parameters

I do apologise if a post like this is not allowed, but I had no where else to go. I watched an explanation on YouTube of function parameters, but it did not make sense. I went to YouTube to see if I could get a verbal explanation of functions since I learn better that way. The YouTube video explained that we have to “call the function” by doing mList[i](), but how in the world is that calling the function when there is no function here called function mList()? The only function is visitCarnival(mList). Video in question is JavaScript Function Parameters - YouTube

const beer_cost = 6.75;
const burger_cost = 5.00;
const pop_cost = 3.00;

let account_balance = 15.75;

// drink beer
function drink_beer() {
    account_balance = account_balance - beer_cost;

// eat a burger
function eat_burger() {
    account_balance = account_balance - burger_cost;

//drink pop
function drink_pop(params) {
    account_balance = account_balance - burger_cost;

let mealList = [drink_beer, drink_pop, eat_burger, drink_beer];
function visitCarnival(mList) {
    for (let i = 0; num = mList.length; i < num; i = i + 1) {

I guess I just still do not understand how mList() is a function if it’s not even a function

Ah ok. Yes, I understand that mList is an array. What makes mList[0] a function? I ask because it is not

function mList (param) }

It looks like a variable wanting the index versus a function

(sorry, learning disability)

The first element is drink_beer

Yes. And what data type is drink_beer?

I believe It is a list

Oh wait. It was a function at the very top

Then made into a list

It hasn’t been made into a list. It’s a function that has been put into a list.

yeah sorry that’s what I meant lol

Right, so it’s still a function, so you can call it, cause it’s still a function.

Lol exactly — I’ve realised that spending hours learning without breaks is NOT the way to go. The next day, I watched the YouTube lesson again and I completely understood why. Thank you all for your assistance.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.