Trying to create a simple function and not sure where the issue is


#1

https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/4?curriculum_id=506324b3a7dffd00020bf661

This is a very simple function code. When called upon it should print out "I want to eat pizza", but I think there is something wrong in the console.log line.
I have tried to not add any " after food and written it like

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

that gives the error message that food is not defined. When I added the " at the end (as in the code below) I get an error message saying SyntaxError: missing ) after argument list. Where is there an extra parantheses?

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

#2

HI this part

...food");

remove the "

And you should call the function foodDemand() instead of food()


#3

I did that just now I am getting the same error message. I have attached a picture of it

.


#4

after eat there are quotation marks ("), this should be one


#5

Thanks now it works.


#6

a little more background information, you can join two strings together by adding a plus sign:

"hello" + "world"

you can also join a string and a variable together:

test="world"
"hello" + test

if you have a variable, don't use quotation marks, this is for strings. you can also insert an additional space in the string you are joining:

test="world"
"hello" + " "+ test

although, i then would prefer this:

test="world"
"hello " + test

put the space simple after hello


#7

thanks that was very helpful.