Stuck with the wrong kind of output



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


Right now your sixth line is calling nameString without any parameter. I think that's what is causing the undefined error.
Try dropping display from your code entirely and then calling nameString("max") directly inside of console.log.


You have a lot of unnecessary/confusing code going on, simplify it:

var nameString = function (name) { // defining nameString function that accepts a (name) parameter
    return "Hi, I am " + name; // returns a string with "Hi, I am MFX88"

console.log(nameString("MFX88")); // prints out function nameString of MFX88 === "Hi, I am MFX88"

or, if you want to use a predefined variable:

var myName = "MFX88"; 

var nameString = function (name) { // this "= function (name)" may be a bit confusing, but it's taking whatever parameter (value, boolean statement, strings...etc) that was passed into it from the call below and temporarily storing into to a local name variable
    return "Hi, I am " + name;



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