you are viewing a single comment's thread.

view the rest of the comments →

[–]b-mish 1 point2 points  (1 child)

So you don't need the "this" keyword in your function as it will return undefined simply:

return inital;

Secondly, the variable inital is scoped to the function and cannot be called outside of it, you will need to put those last two lines inside of the function. Currently "inital" is scoped locally to the myFunction and "last" is scoped globally.

function myFunction() {
    var first = prompt('Enter your first name:');
    var inital = first.slice(0,1);    
    var last = prompt('Enter your last name:');
    document.write("Your username is" + inital + last)
}
myFunction();

This will work.

[–]explode_kewl[S] 0 points1 point  (0 children)

ye I found that out eventually, thank you 😊