NoroffFEU / musikkforandrerliv.no

The Unlicense
8 stars 3 forks source link

Make commented list Blog JS #483

Closed ukonuidika closed 1 month ago

ukonuidika commented 1 month ago

I was able to implement the steps for comments in a blog JS.

Below are my steps for implementing comments in a blog JS.

// Step 1: Define an array to store the comments let comments = [];

// Step 2: Define a function to add a new comment function addComment(author, text) { // Step 2a: Create a new comment object let newComment = { author: author, // Step 2b: Assign the author of the comment text: text, // Step 2c: Assign the text content of the comment date: new Date() // Step 2d: Assign the current date to the comment }; // Step 2e: Push the new comment to the comments array comments.push(newComment); }

// Step 3: Define a function to display all comments function displayComments() { // Step 3a: Loop through each comment in the comments array for (let i = 0; i < comments.length; i++) { // Step 3b: Get the current comment let comment = comments[i]; // Step 3c: Display the comment details console.log(Comment ${i + 1}:); // Display comment number console.log(Author: ${comment.author}); // Display author console.log(Text: ${comment.text}); // Display comment text console.log(Date: ${comment.date}); // Display comment date console.log("----------------------"); // Separator } }

// Step 4: Add example comments using the addComment function addComment("John", "This is a great post!"); // Adding a comment from John addComment("Alice", "I enjoyed reading this."); // Adding a comment from Alice addComment("Bob", "Interesting topic!"); // Adding a comment from Bob

// Step 5: Display all comments using the displayComments function displayComments(); // Displaying all comments

netlify[bot] commented 1 month ago

Deploy Preview for snazzy-moonbeam-86e465 ready!

Name Link
Latest commit 9367578e6f2fe2f26b1bb73f9e64951d9f74071f
Latest deploy log https://app.netlify.com/sites/snazzy-moonbeam-86e465/deploys/661b1601e9eddf0008fc8d30
Deploy Preview https://deploy-preview-483--snazzy-moonbeam-86e465.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] commented 1 month ago

Deploy Preview for dazzling-melomakarona-fe8d9f ready!

Name Link
Latest commit 9367578e6f2fe2f26b1bb73f9e64951d9f74071f
Latest deploy log https://app.netlify.com/sites/dazzling-melomakarona-fe8d9f/deploys/661b1601880da90008cab7cd
Deploy Preview https://deploy-preview-483--dazzling-melomakarona-fe8d9f.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.