What is wrong?


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/3?curriculum_id=506324b3a7dffd00020bf661#

not an error, but this is the output: [Function: nameString]


var nameString = function (name) {
	
	return("Hi, I am" + " " + name);
};

nameString("Sid");

console.log(nameString);


#2

Hi these lines

nameString("Sid");

console.log(nameString);

change it to

console.log(nameString("Sid"));

#3

This is what you're doing.
your asking the console.
console.log(nameString); <---what is nameString?

The console is returning an answer to you;
nameString == [Function: nameString] <-- "nameString" is a function your created above.

Why your line 6 is not working ?

Your line 6 is not working despite the fact that you are calling the function is because in your function,
you returned the values (result) return ("Hi , I am " + " " + name)

To print a return, you need to call your function into a console.log();

like this console.log(nameString("Sid"));

If say, your function ran the > output like this console.log("Hi, I am" + " " + name);

The need to use a console.log() when calling your funciton will be dispensed with; That means you can simply call your function
nameString("Sid"); without the console.log() and it will run <--- and this will easily run in the console.

Just understand when your **> executing_** a function's value immediately, and when you're > returning its value;_


#4

did you forget to put in the ''yes'' answer?
no no no no i havent!
whats the problem? please help!

//story line
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'")

var userAnswer = prompt("Do you want to race Bieber on stage?")

if(userAnswer === "yes")
{
console.log("You and Bieber start racing. It's neck and neck! You win by a shoe lace!")
}
else
{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}


#5

Thank you all, except maybe the last guy. I think he posted at the wrong place!


#6

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