Introduction to Functions in JS 11/13


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;
console.log("Hi, I am" + " " + name)

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


Remove these two lines from your function body:

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

Now outside of the function, write the call expression:

var nameString = function ( name ) {
    // code statement

Note that we pass a string value in quotes.