5 tying it all together problem


#1


What is wrong?


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


#2

Hi this line

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

just remove all the "


#3

Um, I think you should try removing just the last ", but wizmarco probably knows best.


#4

You're both right! Thanks a lot for the prompt help!


#5

@shrike2 yes he/her could also do that but he doesn't need of any space in it..


#6

I have got the same problem.
What is wrong?
// 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("Hello"+ " " +name);
};
greeting("Anya");


#7

You don't need the parentheses before console.


#8

I'm having a bit of trouble here too.

// 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 myName = name;
console.log(myName);
}

name = "asdfghjk";

(Note: it's not my choice of name causing this, I went through like 50 variants before I hit this string of random keys.)


#9

Why do you have in your greeting function this?:

var myName = name;

I'd do something like:

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

and then just call the function:

greeting("asdfghjk");

Sorry, I did this some time ago, dont know exactly what they want from you :slight_smile:


#10

Hey,
I have a problem with this code

Here's mine:

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

// Badly written function with syntax errors!

var greetings=function (name) {
console.log ("Greeting" + " " + name);
};
greetings("Kris")

after entering it I get the following reply "Oops, try again. You did not call the greeting function. Pass it a name!"

Can some give me any clue as to why is that?

Thanks :slight_smile:


#11

So I looked up the task - you didn't go exactly as said in instructions.

You should create function greeting and call it afterwards. Your function is called greetings. That may be a problem :slight_smile:

And btw, don't forget the " ; " to point the end of a command. As far as I can tell, your code here is fine, except of course the ;


#12

It was the "s" in greetings. Thanks a lot for noticing that. It was driving me crazy...


#13

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