Introduction to Functions in JS 11/13


#1

Instructions
Write a function called nameString()
It should take name as a parameter.
The function returns a string equal to "Hi, I am" + " " + name.
Call nameString() by passing it your name, and use console.log to print the output.

//here what i have below

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

};
//also i dont want to just know the code, i want to know why too for better understanding


#2

Remove these two lines from your function body:

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

Now outside of the function, write the call expression:

var nameString = function ( name ) {
    // code statement
};
nameString("bob");

Note that we pass a string value in quotes.