5.Trying it all together (syntax error)


#1

Help me out I am getting a syntax

// 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("Good morning")


#2

so your problem is here. If you are going to put ( ) around console.log you got to finish it by adding another ) after name. You also don't have to have ( ) around console.log like that so you can just delete the ( before console


#3

I deleted the ( before console but I am still getting the same error

// 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("Good morning!")


#4

You need an equal sign between your greeting and function which you had before so idk why it is missing now


#5

Thanks a lot it worked.


#6

Good! Glad to help! Hope the rest of Intro to Functions goes well for you! :smiley:


#7

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