Skip to content
This repository was archived by the owner on Aug 17, 2024. It is now read-only.

Conversation

@BoshraM
Copy link

@BoshraM BoshraM commented Apr 11, 2023

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

</head>
<body>
<h1>
<h1 id ="heading">
Copy link

@jackhclee jackhclee Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the space between attribute name and equal operator

Comment on lines +15 to +16
Name: <input type="text" name="from" placeholder="Your Name" id ="name-id" value =""/> <br />
Message: <input type="text" name="text" placeholder="The message..." id ="message-id" value =""/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name id attribute could be more meaningfully named in consistent manner. identifier-html control type The identifier could be the name attribute of the HTML control. so you may assign id attribute for the 1st input control as from-input and 2nd input control as text-input


<div class="messages-containre" style="border:1px solid black">
<p>all the messages</p>
<div id="message-containre" >

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo containre vs container

let formText = "";

const fetchMessages = async() => {
const response = await fetch("http://localhost:3000/messages");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a const to store the API server host and port info. Avoid manually repeating the host info

}

const fetchLatestMessages = async() => {
const response = await fetch("http://localhost:3000/messages/latest");
Copy link

@jackhclee jackhclee Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference to API host and port info via a variable discussed above

Comment on lines +42 to +56
latestData.data.forEach(message => {
const textMessage=document.createElement("p");
const fromMessage=document.createElement("h5");
const deleteButton=document.createElement("button");
const editButton=document.createElement("button")

textMessage.innerHTML=`${message.text}`;
fromMessage.innerHTML=`${message.from}`;
deleteButton.innerText='Delete'
editButton.innerText='Edit'
latestMessageContainer.appendChild(textMessage);
latestMessageContainer.appendChild(fromMessage);
latestMessageContainer.appendChild(deleteButton);
latestMessageContainer.appendChild(editButton);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code from line 17 to 31 repeated here. Try to factorised

});


app.listen(3000, () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a const to store the port number

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants