Functions Recap


#1


For some reason the only way that this code works is if I input my name as name. If I input anything else it does not work and gives me the error that the name I put was undefined.

How do I change it so that it does not have this problem? (I feel like the answer is really something stupidly simple.)

Thanks for any help.


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

console.log(nameString(name))


#2

Instead of putting name as the argument for the nameString function, use a text string(any word inside quotation marks).


#3

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


#4

Did your code let you pass through to the next exercise?


#5

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