Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make commented list Blog JS #484

Merged
merged 1 commit into from
Apr 14, 2024
Merged

Conversation

ukonuidika
Copy link

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

* add dropdown on Navbar

* update dropdown function
@ukonuidika ukonuidika merged commit 81b86f8 into 258-make-commented-list-blog-js Apr 14, 2024
2 checks passed
Copy link

netlify bot commented Apr 14, 2024

Deploy Preview for snazzy-moonbeam-86e465 ready!

Name Link
🔨 Latest commit d5c33a7
🔍 Latest deploy log https://app.netlify.com/sites/snazzy-moonbeam-86e465/deploys/661c37c03b44e600096be004
😎 Deploy Preview https://deploy-preview-484--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.

Copy link

netlify bot commented Apr 14, 2024

Deploy Preview for dazzling-melomakarona-fe8d9f ready!

Name Link
🔨 Latest commit d5c33a7
🔍 Latest deploy log https://app.netlify.com/sites/dazzling-melomakarona-fe8d9f/deploys/661c37c0859930000877cdb1
😎 Deploy Preview https://deploy-preview-484--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.

@ukonuidika ukonuidika requested a review from a team April 14, 2024 20:11
@ukonuidika ukonuidika self-assigned this Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants