Need help re-using a user's name throughout my game

Hello! I am making a really easy game in JavaScript and i need to reuse a character’s name throughout the game. Do you see a problem with this code? NOTE: I am sorry if this post is not in the right category. I have no idea what I am doing on that factor.
var userName = prompt("What is your name?"); if (userName.length > 8) { return "You have a very long name," + userName; } else { return "You have a very short name," + userName; }

It looks like you are checking the length but we cannot see a length property.

1 Like

Yes sorry, i realized that problem and fixed it. However, it still gives me the error that the script is invalid. I am assuming it is because of the + userName, but I’m not sure.

The error in this case would be something like, “return not in function”. Try console.log() instead.

1 Like

It works! Thanks a lot, mtf.

1 Like