Stuck on 11


#1

When I press the continue button I get this error message
"Did you create a function called nameString?"
var nameString = function (name) {
return "Hi, I am"+" "+ name;

};
nameString= "Dylan"

Bit confused


#2

Change

nameString = "Dylan"

to

nameString("Dylan");

#3

thank you! That is great!


#4

My code was
var nameString = function (name) {
return "Hi, I am" + " " + name;
};
nameString("Herardo Jones");
, and
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?
appeared when I clicked the save and submit button.


#5

@herardojones. u forgot to include
console.log(nameString);
under
nameString("Herardo Jones");


#6

No actually console.log(nameString); will just output [Function] which is correct as nameString is a function but you probably rather want to print the returned result by:

console.log(nameString("Herardo Jones"));


#7

I am using this as an answer , and my output is Hi my name is Susie,

but I wont let me pass is there something I am missing. Thanks!

var nameString = function (name) {

return "Hi,I am"+" "+name;

};

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


#8

u have to use nameString above your console.log like so:
nameString ("Susie");
console.log(nameString("Susie"));

and u have to use parenthesis for - "Hi,I am"+" "+name;


#9

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

};

var nameString ("Kevin");

};

dont know whats wrong


#10

var nameString = function (name) {
    return "Hi, I am"+" "+ name;
};
var nameString ("Kevin");  //This messes up the function nameString
};

||
V

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

#11

Please format your code. It should look like this:

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

var nameString ("Kevin");

};

Once you define nameString using var, don't define it again. You can call it simply like this:

nameString("Kevin");

This function returns a value but you don't capture it, so if it doesn't seem to do anything, that's why. If you want to print the value to the log, call it like this:

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

#12

thanks this all helped


#14

Not sure what is happening:

Here is my code:

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

{
nameString("Ari");
}

For some reason, it prints:

Hi, I am Ari
Hi, I am Susie

The word, Susie, doesn't even appear in my code! I have no idea why it prints twice.

Thanks for all help.


#15

I figured out my problem (not using the return) but perhaps look into my issue? If it's a bug, it really makes things confusing.


#17

Hello I have found probably bug cause my code is good and its still not working;

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

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

works perfectly but program still wont let me go to next lesson


#18

||
V

"Hi, I am"

#19

bro when i do console.log(nameString("Sheryar");
it says console.log isn't a function. so i did this
console.log=(nameString("Sheryar"));
and gets me the desired result but this msg :
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?
still presists!!!! idk what to do


#20

Sry for the late response. With name = VALUE you overwrite the initial value of name with VALUE. So in your case:

console.log=(nameString("Sheryar"));

you overwrite console.log with the value returned from nameString("Sheryar"). The reason why this prints something is because the last value used in your program is echoed to the screen. Test it just write "test" on a blank exercise and you should see 'text' in the console. But this is not a reliable output and only works for the last statement (and if it is not undefined). So console.log(nameString("Sheryar")); would actually be the way to go. The problem is just that now console.log is no longer a function (it is "Hi, I am Sheryar" which is a string and can not be called to print stuff to the console. So before you can run the correct code you need to refresh the page in order to reset console.log to it's printing functionality. Also you're function call lacks a ). console.log(nameString("Sheryar");

Hope this is useful.


#21

I have tried several variations, including some suggestions I've found in this thread, but it seems like nothing is working on this one. With the code below, I get the following error: "Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie." Can someone help me understand where
my syntax error is?

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

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


#22

Nevermind...My error was in adding a period.