Will somebody explain 6/13 please


I am very confused please help:)


So I found the answer but if somebody would please explain how they got this answer, thanks!

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


I had a hard time with this one too, but I figured it out on the Q & A forum too. I understand your troubles with functions; I'm still having them now! And trust me, it's going to get a lot harder. But... I made it through, so I'm sure you can too. As far as I know, I was never stuck for more than a day, two if it was really difficult. Now, let's talk functions. I'm going to share with you all my function knowledge, which actually isn't that much because I consider myself a beginner who simply likes to help people where I can.
The basic formula for a function is this:

var functionName = function(arguments) {
do something here

To call a function, it looks like this.functionName(arguments);
Now, let's talk about each of these elements in turn. First, you have to make your function's name. Simple, and the standard way to name it is one word made of two, the second capitalized. Next is what makes your function, well, a function. Telling the computer that it's a function is just the word "function" before your arguments. Hold up-- what's an argument? This is a temporary "variable" you will "declare" when you call the function. It tells the computer the things it will need to know in order to run the function. For example, in this function, the only argument is "price". The price is, as I said, what the computer needs to know in order to run the function. If it didn't know what "price" was, then it wouldn't have any numbers to run the function with. The key here is thinking like the computer.
The next part is simple. You tell the computer what you want it to do. For example, here you want it to multiply the price of the oranges by five and print that out onto the console, so you'd type:
console.log(price*5) as you did. Also, it's never a bad idea to add a semicolon after console.log. Then, you close what you want to do with the curly brackets.
Finally, calling the function. Make sure you call the function outside of the function. How you do it is: first, you type in which function you want to call, then declare your argument "variables" in parentheses. Here, the orange cost is 5, so you type in 5 in the parentheses obviously. A semicolon finishes your calling, and -- Voila! A function!
Hope it helped.


I hope you don't mind reading super long posts... And that you don't think I'm long winded. I just want to help.


nicely explaned good use of language


Thanks a lot that really helped!! I really appreciate the long response!


Great answer just some adjustments concerning the names. The function name could be anything a good rule of thumb is to describe what the function is doing and in case this needs more than one word camel case is what makes it easier for humans to read it (e.g. functionName) another way would be the underscore variante function_name. And the other think is the use of the term argument.

var functionName = function(arguments) {

here the variable that you named argument is actually a paramter. Arguments are the value you pass to the function call. Using these names should make it easier to google it and also avoids confusion because in the () of the function call you use value not variables. Anyway great answer!


Really? I sometimes find it annoying to have to read all that... I didn't want to give a super long answer that was hard to understand, but I took a "risk".


Hahaha yes really it helped a lot and I keep looking back it it. It has a lot of good info thanks!


Awww... Thank you.