Lesson 11 has an error, I'm sure


#1



First I typed the code with return inside of function because instruction said under 3) it should "return" the whatever, and under 4) it said I should use whatever name I want as function parameter. So I used Theodore Roosevelt and it printed "hello I'm TR" and "Hello I'm Susie" and it told me it didn't print "Hello I'm Susie" - if the lesson said to use name Susie I'd get it, but it didn't. So I changed TR to Susie, and now it printed twice "Hello I'm Susie" and told me I didn't use console.log, which the instruction didn't tell me to use in the first place, so I added console.log, and now it didn't print anything, just told me I have syntax error.

At this point my console.log was inside of function, and once I moved it outside of function it printed only "Hello I'm" and gave me green to proceed.

code that doesnt work properly but lets you pass the lesson is:

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

I moved the space inside of "Hi, I'm", that can't be why the code doesn't work.


#2

this line

nameString("Susie");

try to put the nameString("Susie"); inside a console.log()


#3

like this

console.log("Hi, I am " + nameString("Susie"));

that works, but I don't get why the other one doesn't work? It's not like the result of the function is local variable so it doesn't work outside of function. And it turns out, function is now just a parameter of the function, cause return isn't printed out, so function hardly does anything.


#4

this part

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

name is a the argument of the function nameString() so when you do that

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

only print Hi, I am then that should normally works

nameString("Susie");

but the lesson aske you to

4. Call nameString() by passing it your name, and use console.log to print the output.


#5

Hi, the return keyword already store the value to the call function with ," Hi, I am Susie".

var nameString = function (name ) {

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

};

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