Need help on lesson 12 functions & if/else


#1



Lesson 12 function & if/else


error message syntax error


Replace this line with your code.


#2

To write a function we start by blocking it out. This is a first step that we will build upon.

var myFunction () {

};
myFunction();

Above we have prepped both the function body and the call expression. We will fill these in as we go. The finished product will be at the end.

Next let's define the parameter.

var myFunction (param) {

};
myFunction(8);

The above assumes our function will be expecting a number value as the argument.

Now let's block out what the body code will look like. It is an if..else statement so will be structured like so...

    if () {

    } else {

    }

Blocking is what helps us keep sight of the syntax and structure. It's easier to build code when we have the right structure and just need to fill in the details.

Now let's combine our structures into one block:

var myFunction (param) {
    if () {

    } else {

    }
};
myFunction(8);

Start with the above structure, giving the function the name expected as given in the instructions. Be sure to change both the function name and the call expression name to match. Change the parameter name to match the instructions as well. Use only the variables specified.

The instructions provide two string literals. Log them in each case, and use the exact text and punctuation. It must be exactly as given.


#3

It worked -Thank You & Double Thank You