11. Functions recap


#1



Hi 
my code keeps telling me i haven't printed anything in the console, although it clearly says: Hi, I am Cameron.

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


#2

Use the console.log method to print to the console.

I will give you a hint and say you need to wrap something already in your code, inside a console.log() statement


#3

but still it wont show HI I am cameron


#4

Try wrapping your return in ()

return("blahblah");

and print nameString to console...

console.log(nameString("cameron");


#5

Hi, guys, I have the same problem :
var nameString = function (name) {
return "Hi,I am" + " " + name;
};

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

Can you tell me what's wrong?


#6

never mind, it was a SPACE missing between Hi, I


#7

ok so i keep getting this error message "Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie."when my console and program is clearly working at it displays "Hi, i am Susie"

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


#8

Capital I for i need to have the correct spellings/punctuation.

and never put console.log = something

it should be

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


#9

so now whats the problem?


#10

I'm having similar issues... with the code below (leaving out the console.log portion) it is telling me that nothing is printing... which I understand.

var nameString = function (name) {

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

};

nameString("Dave")

When I add the proper console.log portion, as I keep seeing in the forum threads for question #11, it is telling me that "TypeError: console.log is not a function"

var nameString = function (name) {

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

};

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

... Please help me to understand what I'm doing wrong here.


#11

Refresh the page and resubmit, you overwrite the function of console.log by putting it as console.log = .


#12

Hey db,

If you refresh and resubmit that should work, you can clearly see here that your code works fine

http://jsbin.com/rekivaquzu/edit?html,js,console,output

(click run with js on the right)


#13

hehe you were right thanks for the refresh the page tips


#14

Hi there,
your method worked but there's one question need to ask.. what is the need of "nameString" inside console.log() as in 'console.log(nameString("cameron"); '


#15

I love how cool your background is. :smiley:


#16

Weird thing. I think my code is right, but I get an error: 'Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie.'

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

Who's that Susie and what is she doing in my code? 0_o


#17

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

nameString("Susie");

I use this code pass!


#18

You dont need the + "" part because you wrote I am " which is giving it the space already,

"Hi, I am " + name or "Hi, I am" + " " + name

Hope you understand what I'm trying to say


#19

Give it a refresh and try to resubmit, if that doesn't work it might be the issue of spacing things

Try this

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

#20

Thank you! I've copied code from another topic, so now I'm called Al :slight_smile: It has worked.