Semi-colon problem 5/13


#1

Why does it say SyntaxError: expected ' ; ' when my code is like this?
// Nicely written function:
var calculate = function (number) {
var val = number * 10;
console.log(val);
};

// Badly written function with syntax errors!

greeting var function(name){
console.log(name)
};
name("master")


#2

you try to solve this line.


#3

but I'm asking why it's telling me that it expected a semi colon when I had it in all places it should be in


#4

I think you need one after the console.log....


#5

alright... nope it didn't work.


#6

This is my code:

// Nicely written function:
var calculate = function (number) {
    var val = number * 10;
    console.log(val);
};

// Badly written function with syntax errors!

var greeting = function(name) {
    console.log(name);
    greeting("Bammy");
}

I think you should first correct your function...

And compare!


#7

greeting var function(name){
at this line , compiler understand that greeting a variable and so it is needed a semi-colon.


#8

Thank you! I had some code in the wrong place and missed an equal sign. Thank you


#9

the FUNCTION talk

var myFunc = function( param1, param2) {
       //Begin of  anonymous FUNCTION-BODY
       //VARIABLE -myFunc- has an -anonymous function- assigned
       //this -anonymous function- has 2 PARAMETERS param1 and param2
       //param1 and param2 PARAMETERS are used 
       //as -local- VARIABLES throughout the FUNCTION-BODY

      console.log( param1 + " and " + param2 ) ;

      //End of anonymous FUNCTION-BODY
};

If you want to call/execute the anonymous function
you will have to add a pair of parentheses to the variable myFunc
like
myFunc();
As the anonymous function was defined
as having 2 parameters
you have to provide 2 arguments
in our case 2 string VALUES "Alena" and "Lauren"
like
myFunc("Alena","Lauren");

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**