Hello, Replit Community. If you run this, the program should first ask you for a username. However, if you then type a message, it doesn't display it onto the chat. So please help. I will be rewarding whoever that answers this 5 upvotes!
Change the (line 45 index.html)socket.emit(username + ': ' + 'chat message', input.value + ' ' + datetime);
to socket.emit('chat message', username + ': ' + input.value + ' ' + datetime);
You're append to the name of the emitted "signal", meaning when you detect it, it won't match the socket.on('chat message') call. Instead, it is emitting "<username> : chat message" as the title instead of chat message.
Change the (line 45 index.html)
socket.emit(username + ': ' + 'chat message', input.value + ' ' + datetime);
to
socket.emit('chat message', username + ': ' + input.value + ' ' + datetime);
You're append to the name of the emitted "signal", meaning when you detect it, it won't match the
socket.on('chat message')
call. Instead, it is emitting"<username> : chat message"
as the title instead ofchat message
.