Showing error!


hii,i am stuck and i reaaly dont knw where i want code is-
var nameString = function (name ) {
return "Hi,I am"+" "+name
var intro=nameString('Arushi');

and its showing error-
Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie.
i am not able to rectify it.



Why are you setting var intro? Why not just console.log(nameString("NAME"))

You'd be printing what the function returns.


okk,but bt wats wrong in dat...?


Well strictly from a coding logic standpoint, why would you set a variable to something that is already set? You have a whole extra line to do that. This is simple code, but in more complex code, you might end up writing a lot of extra lines. One of the reasons it may not be working though is that the instructions tell you to write one function that logs, and does not return. Then call the function with a parameter.


okk...but den also its showing d same error...


It might be the codecademy interpreter, because the instructions told you to write a functions that logs, and does not return. That way you can just call the function and it will log.


This is the format you should use for this little code.

var firstvariable = function(name) {
    var secondvariable = name;

Follow this little pattern and your code should work once realigned with a reasonable structure


The function returns a string equal to "Hi, I am" + " " + name
the instruction says to return...


What lesson are you on? I may have assumed the wrong one


functions itroduction to function in js


Yes my bad. So your first part is fine

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

However, your second part is wrong. You just need to console.log the variable and the name inside of that. For example:


Sorry for the confusion!


its okk...but its not is again showing d same error...


Paste your code and let me see then


here it is-
var nameString = function (name ) {
return "Hi,I am"+" "+name


It is your formatting in your spacing that is leading you astray here. Copy and paste this spacing in and it should pass. I just passed it in my lesson with this so you should be good.

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



Sorry it looked like you were on 3.


Yeah I thought the same thing lol Thankfully I think we have righted the ship


yap...u were right...i just hope it is codecademy interpreter only...or spacing formatting is also checked...?
thnxxx... :slight_smile:


Sometimes spacing can throw of the codecademy interpreter. It is very important in some languages like Python. Plus if you learn to space your stuff out right in languages that don't require it, it will make it more readable.


Yes, one of the things I had to learn is you can't just do whatever spacing or line up you want. It is not so much in java-script as in other computer languages like python but you do have to organize your code properly or even if its right it won't work. Hopefully your other coding will be a little less confusing and good luck!