Tying it all together


#1



https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/5?curriculum_id=506324b3a7dffd00020bf661


I am getting an error "SyntaxError: 'Expected ';'


var greeting = function(name){
console.log("Hello" + " " + name);
};
greeting("Tara")


#2

The code looks fine when I ran it the console accepted it as correct can you include a screen shot.


#3

You may have altered some of the other code on the page rendering the error.


#4

Sorry having problems uploading screen shot. I have tried by resting code several times but still does not work


#5

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

// Badly written function with syntax errors!

greeting("John")

And it worked!


#6

Thanks but according to the question I have to rewrite this badly written code
greeting var func{name}(console.log(name)))}

I tried
var greeting = function (name){
console.log("Hello" + " " + name);
};
greeting("Tara")

but keep getting syntax error


#7

i see what your problem is now you need to comment out the original "badly" written code

//greeting var func{name}(console.log(name)))}

#8

or just delete that chunk all together. your code is good though


#9

Thanks heaps for the help. I have been puzzling over this for sometime. I works now when I comment the badly written code


#10

No problem glad I was able to help, I know I've been in the same position before staring for days trying to find out were I went wrong and usually it was some sort of typo or something I was missing.


#11

you can use this if you have any problem
var greeting = function (name) {
console.log("hello," + " " + name);};
greeting("shiv");


#12

Here's mine and no error...

var greeting = function(name){

console.log("Hello" + " " + name);

}
greeting("Jas");


#13

@webplayer75133

Thanks for your help. Got it


#14

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