11. Some confused with this exercise


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/3

I think, this is more correct code to pass an exercise

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


after submit code we will have in console "Hi, I am Petr" - but I recieve caution
"Oops, try again. It looks like you didn't print anything to the console! Did you remember to console.log() the result of passing your name to the nameString() function?"

Also, I have pass this exercise with code
.

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

but in console we will have "[Function: nameString]"

Is this the correct exercise?


#2

Hi for your second code these line

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

put it like that

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

Your first code

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

it's because you call teh function indide it so you could just remove this line

console.log(nameString)

then pu this line

nameString ("Petr");

inside the console.log()


#3

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

};
console.log(nameString("dj"));

Its clear in instructions that we need to call the function through console.log.


#4

Hi,

I have tried the following but am still getting the same error. Could you help me?

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

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


#5

Alternatively, have tried the following as well and still can't progress, though the result is the desired one.

var nameString = function (name) {
return "Hi, i am" + " " + name;
console.log(nameString);
};

nameString("Jon");


#6

Write the exact line they want. 'I' should be in caps and check out the blankspace. Try it and see.


#7

try with this one
it does work with me

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

};
nameString ("your name is here");
console.log (nameString("your name is here"));


#8

The coding makes sense, but anyone else getting a message about Susie??


#9

That is strange, but change the line console.log("Hi, I am" + " " + name); to return "Hi, I am " + name;.


#11

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