Help on 5/13


#1


Hey I am new to JavaScript, can you guys help me out?

3.Introduction to functions in JS 5/13.

SyntaxError: Expected identifier


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

// Badly written function with syntax errors!

var greeting = function(dog) {
    console.log("I want to say hi to " + " " + dog );
    function greeting("dog");
};


#2

This is not the proper way to call a function


#3

Can you show me the correct way? Thanks!


#4

You need to take

this line and move it to outside of the function, after the

Also, you need to call it without the function keyword and it would look like this:

greeting("dog");

#5

Ah. Thank you so much!


#6

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

// Badly written function with syntax errors!

var greeting = function (name)
{
var bi="bi "+name;
console.log(bi);
};
greeting("cao");


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.