![]() |
|
12-20-2013
|
16 |
|
Professional AFKer
Join Date: Sep 2011
Location: South East Pennsylvania
Posts: 1,888
|
gosh darn curly brackets screwing up all my stuff.
|
|
12-21-2013
|
17 |
|
Registered User
Join Date: Mar 2012
Location: In your heart
Posts: 2,813
|
I really like this. But I can never really get into it for more than a few weeks. I'll just drop it one day. I do that with a lot of things though.
|
|
12-23-2013
|
18 |
|
Back from the dead?
Join Date: Feb 2013
Location: Australia
Posts: 2,533
|
I need a bit of assistance with the JavaScript tutorial. If anyone could help me, I would be grateful! These are the instructions: You are a creature of habit. Every week you buy 5 oranges. But orange prices keep changing! 1. You want to declare a function that calculates the cost of buying 5 oranges. 2. You then want to calculate the cost of the 5 all together. 3. Write a function that does this called orangeCost(). 4. It should take a parameter that is the cost of an orange, and multiply it by 5. 5. It should log the result of the multiplication to the console. 6. Call the function where oranges each cost 5 dollars. -----this is what I coded so far --- var orangeCost = function (orangeCost) { var price = number * 5 } console.log(price = 4) |
|
12-23-2013
|
19 | |
|
Registered User
Join Date: Sep 2011
Posts: 963
|
--- try this; var orangeCost = function (price){ var cost = price * 5; return (cost); }; orangeCost(5); |
|
|
12-23-2013
|
20 |
|
Back from the dead?
Join Date: Feb 2013
Location: Australia
Posts: 2,533
|
|
|
12-23-2013
|
21 |
|
Registered User
Join Date: Sep 2011
Posts: 963
|
|
|
12-23-2013
|
22 |
|
Back from the dead?
Join Date: Feb 2013
Location: Australia
Posts: 2,533
|
It worked, thanks iDylan!
|
|
12-23-2013
|
23 |
|
Registered User
Join Date: Sep 2011
Posts: 963
|
|
|
12-24-2013
|
24 | |
|
Zone Player
Join Date: Feb 2013
Posts: 697
|
|
|
|
12-24-2013
|
25 | |
|
Should be fixed.
Join Date: Aug 2011
Posts: 6,359
|
var orange = 5; var orangeCost = function (price) { console.log(orange * price); }; orangeCost(); I thought the point of it was that the price is always changing, hence why the function takes a parameter for the price. |
|
|
12-25-2013
|
26 | |
|
Registered User
Join Date: Sep 2011
Posts: 963
|
.
|
|
|
12-25-2013
|
27 |
|
Back from the dead?
Join Date: Feb 2013
Location: Australia
Posts: 2,533
|
var myFunction = function (Parameter) Is the parameter a variable? |
|
12-25-2013
|
28 |
|
Registered User
Join Date: Sep 2011
Location: Chicago, IL
Posts: 1,992
|
The parameter is the variable you input into the function.
|
|
12-25-2013
|
29 |
|
Registered User
Join Date: Aug 2011
Location: En La Caja
Posts: 1,679
|
Yes. So, for example: PHP Code:
|
|
12-25-2013
|
30 | |
|
Back from the dead?
Join Date: Feb 2013
Location: Australia
Posts: 2,533
|
|
|