orangeCost


#1

This is what I got but it just isn't working. Not really sure what I am doing wrong. Keeps giving me SyntaxError: Unexpected token (

var orangeCost(price) = function {
console.log("5 *" + " " + price);
};

orangeCost("$5.00");


#2

You are supposed to add a parameter AFTER the function, so it will look like this:

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

you want to put the parameter first when doing the second line in the function
The last line multiplies the two things: the function and the number of oranges

I hope this helped


#3

var orangeCost = function (price) { <----------there is no semi colon required here.


#4

Hi, don't forget that the syntax for a function looks like this

var sayHello = function(name) {
    console.log('Hello ' + name);
};

So where you put

var orangeCost(price) = function {

you should instead have

var orangeCost = function(price) {

Hope this helps


#5

It said in all of the descriptions that there is supposed to be a semicolon after every line in the function after the brackets datarockstar64796


#6

Try it.

After every line of code after the brackets.


#7

Thank you for your help guys. Your advice helped. I see where I screwed up now. My parameters were misplaced as you stated. I had to put it after the function declaration instead of the function name.


#9

So these codes worked for me.. I was able to click the green Next button, but I didn't see what I expected I should see printed to the console.
Can anyone explain why?

CODE 1: Console printed Undefined -----------------------------------------------------------------------------------------

var orangeCost = function (orange){
var bulkOrange = (orange*5);

};
console.log(orangeCost(5));

CODE 2: Console printed 25 and Undefined on separate lines.-------------------------------------------------------

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

};
console.log(orangeCost(5));


#10

You should see 25. As far as you're not asked to use return the second version is almost correct. The only problem is that you wrap your function call in a console.log meaning you ask to see the value of a statement that has no value. Just get rid of this wrapping console.log on the last line and it should be ok.