4/13 SyntaxError: Expected ';'


#1

This is my code
var foodDemand (food) {;
-console.log('I want to eat' + " " + food);
};
foodDemand('Burgers')
The name is my error
each - is a whitespace/gap


#2

var foodDemand (food) {; //Take out ending semi-colon  / And make 'var' = 'function'
-console.log('I want to eat' + " " + food); //take out '-' at beginning of line.
}; //semi-colon not necessary here
foodDemand('Burgers') //add a semi-colon to the end of this line.

I think those are all the changes you need to make. Otherwise your code should look like this when you're done:

function foodDemand(food){
  console.log('I want to eat' + " " + food);
}
foodDemand('Burgers');

#3

var foodDemand (food) {;

// the semi-colon is to end something and here youre just begining.

-console.log('I want to eat' + " " + food);

// here you use ´ ´ single , you should use ¨ ¨ double ones...

};

foodDemand('Burgers')// use ¨ ¨

The name is my erroreach - is a whitespace/gap
[/quote]

nad thats all I can remember now... hop It helped.


#4

in addition to what @lolman and @mara15 have said take a look at this

//we define a variable foodDemand but we are saying its a function
// it takes in one argument 
//so whenever we call foodDemand we have passa value to it
//
var foodDemand = function(food) {
    console.log('I want to eat' + " " + food);
};
foodDemand('Burgers');


//Note this is another way to define functions
/*
function foodDemand(food){
    console.log('I want to eat' + " " + food);
}
foodDemand('Burgers');
*/

#5

Actually in JavaScript the parenthesis, and apostrophe " and ' are interchangeable, and they do not need changing. However it's best in coding practice to find certain ways to incorporate both to help sort through code. Again this is not necessary for the code to work.


#6

as @rydan said. There's a couple ways to declare function variables. And it's best to get incorporated with each as they have their benefits, but for all surface reasons they are the same.

So writing either:

var foodDemand = function(food) {
    console.log('I want to eat' + " " + food);
}; //This function requires a semi-colon after closing the bracket.

Or:

function foodDemand(food){
    console.log('I want to eat' + " " + food);
}

Will work. Just keep in mind there are plenty of differences between the two, such as the first one needs a semi-colon after its closing bracket, where the second one does not. There are plenty more differences that can be found here.