Exercise 4 JavaScript - help please


I'm just trying to work out the issues with the below code as its not working?

var foodDemand = function(sausage) {
console.log("I want to eat" + "egg" + foodDemand);



The idea of a function is that you can reuse code e.g.

var test1 = function(){
    console.log("This is just a test");

now whenever you want to write "This is just a test" you can just use test1(). But this will only print a hard coded string if you want different things to happen than you can use the parameter e.g.

var test2 = function(warning){
    console.log("This is just a "+warning+". Nothing to see here");

Now you can run it and see different results e.g.

test2("test") --> "This is just a test. Nothing to see here"
test2("warning") -->"This is just a warning. Nothing to see here"
test2("mattweb") --> "This is just a mattweb. Nothing to see here"

So a parameter is just a local variable inside the function that gets it's value from what you use in the () of the function call which lets you use the same function for different things. If you combine this with conditions you may already see that this can be a really might tool, isn't it?