Functions Recap


#1

var nameString = function (name) {

console.log("Hi, I am" + " " + name);
};

nameString("Lee");

The response in the right have then returns

Hi, I am Lee
Hi, I am Susie

This then errors. I have made no mention of "Susie" in the code, very very confusing.

I assume this is a bug in the page?

Thanks

Lee ( Not Susie :slight_smile: )


#2

Hello Lee :slight_smile:

Extra output is the result of the SCT, tests that codecademy uses to check if your code is correct :slight_smile: So this is not a bug, it's a feature.


According to instructions your function should return this message, not print it out to the console.

And in the last line, you are supposed to use console.log to print to the console result of the function call.


#3

Hi Lee,
I also got the same thing.In the instruction they ask to put return statement.Again instructs to give console.log().Its confusing.
In your code if you give return instead of console.log(),you will get output,but with the error.


#4

In the function, you have to use return. And you also have to use console.log in this exercise to print to the console result of the function call (console.log(nameString("Lee"));).


#5

Thanks for the help with this. I'll read the instructions more carefully in the future.


#6

You're very welcome :slight_smile:


#7

2 posts were split to a new topic: I typed the code below..but still showing result with error


#11

3 posts were split to a new topic: I'm having the same problems


#15

4 posts were split to a new topic: Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie


#16

A post was merged into an existing topic: I'm having the same problems


#18

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