Currently facing a challenge with adjusting the number of likes and comments using increment for properties 'numberOfLikes' and 'comments'. Unsure whether to utilize a for loop or just the increment operator. Still new to coding, so apologies in advance.
/* Add to the existing skeleton of a Tweet class in the space provided below.
- A tweet should consist of an (dynamic) author, content, timeStamp, numberOfLikes, and comments.
- A tweet should be capable of incrementing the numberOfLikes and adding to the list of comments.
Create multiple instances of your Tweet and log them to the console. Ensure that the tweet object instances perform as expected. */
class Tweet {
constructor(author, content, timeStamp, numberOfLikes, comments) {
this.author = author;
this.content = content;
this.timeStamp = timeStamp;
this.numberOfLikes = numberOfLikes;
this.comments = comments;
}
};
//This is code I experimented with, but it's not functioning
this.add = function(numberOfLikes){
for(i = 0; i < numberOfLikes.length; i++){
console.log("You have " + numberOfLikes + " likes");
}
}
this.add = function(comments) {
for(i = 0; i < comments.length; i++) {
console.log("You have " + comments + " comments");
}
}
var tweet1 = new Tweet("Rihanna", "Fenty Beauty", "12:31 A.M.", 120193, 6782);
Appreciate your help!