Please help me understand this.
No tutorial video has shown me how to work with multiplying or defining functions with parameters. Does anyone have an example that this lesson is trying to teach me?
Voters
No tutorial video has shown me how to work with multiplying or defining functions with parameters. Does anyone have an example that this lesson is trying to teach me?
Looks like python..
ok.. um.
When defining a function in python, simply state it with the def key word like so.
this is what I have....what am I doing wrong?

@Highwayman
@JonMarsh actually that looks like js in which case I will have to show you because all you syntax is correct but it ins’t doing what they asked at all. Let me walk you through it.
first, you define your function as you have:
(I will use obj instead of object since object is too close to the Object keyword)
Now that we have a function with an object guaranteed to have only numbers in it, we figure out a way to loop through the object. To do this we will use to super cool features of the Js language: the
of
keyword and theObject.keys()
function.There are many ways to use the for loop, on of these ways is called a ranged based for loop, this involves the of operator. Basically the way you use the of operator is when you declare a for loop and the var inside of it, instead of initializing the var to a number you say
of
and then the name of the array your going to be looping though. The var then automatically holds the next value of the array in the loop throughout. It’s quite handy. Here’s an example:That will output
The
Object.keys()
function takes a single json object and returns an array with all the current valid keys/members of that object.Here’s an example:
Now we are going to use the of keyword to loop through all the keys generated by the object.keys() function to multiply the members together and return the result.
Yay.
wow very in depth, thank you. I will see if I can understand [email protected]
what is "i" again? what does it [email protected]
@JonMarsh maybe. I still don’t know what language you are using so that’s js. What language are you using?
@JonMarsh i is just a representation of the first variable you declare for that for loop. It’s a super popular convention actually to name that variable i.
for(var i = 0;i < 10;i++) // the var could be named anything, but I was calling it i.