What is wrong?



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

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




Hi these lines



change it to



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;_


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!")
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")


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


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