Your First Chat Message

Who is chatting

In order to have an effective chat application, we need a way to tie each message to the person who is sending it. To do that we will ask each user for their name.

Prompt for Name

This is some JavaScript logic that prompt a user for their name. This simulates an authentication experience without actually authenticating the user. Full user authentication using Firebase is covered in a later section of the course.

With JavaScript, we check to see if the key of name is in localStorage. If there is not a name then we ask for it with the browsers built-in prompt. Then, after we have the name supplied by the user we can store it to localStorage. If there is a name in localStorage before we load the page we use that for our app. This would happen if you supplied your name earlier, closed the app, then returned later. localStorage would remember what name you had supplied previously.

Get hands-on with 1200+ tech skills courses.