Advertisement
VladNitu

miriStruct

May 30th, 2023
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. class ArticleData {
  2. constructor() {
  3. this.urls = [];
  4. this.titles = [];
  5. this.publishers = [];
  6. this.dates = [];
  7. this.similarities = [];
  8. }
  9.  
  10. addArticle(url, title, publisher, date, similarity) {
  11. this.urls.push(url);
  12. this.titles.push(title);
  13. this.publishers.push(publisher);
  14. this.dates.push(date);
  15. this.similarities.push(similarity);
  16. }
  17.  
  18. getArticle(index) {
  19. return {
  20. url: this.urls[index],
  21. title: this.titles[index],
  22. publisher: this.publishers[index],
  23. date: this.dates[index],
  24. similarity: this.similarities[index]
  25. };
  26. }
  27.  
  28. getAllArticles() {
  29. const articles = [];
  30. for (let i = 0; i < this.urls.length; i++) {
  31. articles.push(this.getArticle(i));
  32. }
  33. return articles;
  34. }
  35.  
  36. // Add any additional methods or functionality you need
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement