Number 11 on Introduction to Functions has a bug


#1

Whenever I submit code to say "Hi, I'm Fred" it will show that, and then right below it, it will show: "Hi, I'm Susie" I don't know anyone named Susie, and I did not code that part. It will show up with an error message after that.


#2

please copy and paste the error message here.
and show us your code.

Thx


#3

I am having the same problem.

var nameString = function (name) {

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

};
nameString ("Buttercup");

When the above code runs, I get
Hi, I am Buttercup
Hi, I am Susie

The error message states:
Oops, try again.
Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie.

I know I'm missing something about the return command, but where the heck did Susie come from?

Thanks!


#4

Cause you two didnt read carefully the instructions

Your function should return something and dont print something.

This is wrong

var nameString = function (name) {

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

};

#5

Susie is an example how it should looks like :smile:


#6

So what is the fix? I did read the instructions.
Thank you kindly.


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

And Susie is gone :wink:


#8

try inserting Susie into the function call like this: nameString("Susie");
I believe that it outputs Hi I'm Susie to compare your output to the output they want.


#9

Thank you! Now it makes sense.
I wish there was a way to go back to previous lessons or show previous learning to refer to.


#10

@micromaster54926

There you can switch


#11

Thanks! That helped a lot!


#12

Yeesh. This lesson really kicks it up a notch. I feel like lesson 8 kinda skims over how important 'return' is when defining a function =/