Adding the ChatMessage Class

Chatting between two terminals is fun (and makes you look cool at the coffee shop), but it is time to upgrade to sending messages from browser to browser. You will write a helper class that handles constructing and formatting message data.

There are three pieces of information you will want to track for each message. You need to know the text of the message, who sent it, and at what time.

JavaScript Object Notation – more commonly known as JSON (pronounced “Jason,” per creator Douglas Crockford) – is a lightweight data-interchange format. You have already been using JSON for your package.json file. It is human readable and language independent, and it is ideal for sending and receiving the kind of data ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.