From 44ee154c583045078fe321b749238a0e457a7b27 Mon Sep 17 00:00:00 2001 From: Anirudh Negi <4nirudhnegi@gmail.com> Date: Fri, 7 Nov 2025 15:29:01 +0530 Subject: [PATCH] Updated files with comments by Anirudh --- 03-reviews/final/app.js | 61 +++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/03-reviews/final/app.js b/03-reviews/final/app.js index b7aacba1..2ad19d21 100644 --- a/03-reviews/final/app.js +++ b/03-reviews/final/app.js @@ -2,48 +2,55 @@ const reviews = [ { id: 1, - name: 'susan smith', - job: 'web developer', - img: 'https://www.course-api.com/images/people/person-1.jpeg', + name: "susan smith", + job: "web developer", + img: "https://www.course-api.com/images/people/person-1.jpeg", text: "I'm baby meggings twee health goth +1. Bicycle rights tumeric chartreuse before they sold out chambray pop-up. Shaman humblebrag pickled coloring book salvia hoodie, cold-pressed four dollar toast everyday carry", }, { id: 2, - name: 'anna johnson', - job: 'web designer', - img: 'https://www.course-api.com/images/people/person-2.jpeg', - text: 'Helvetica artisan kinfolk thundercats lumbersexual blue bottle. Disrupt glossier gastropub deep v vice franzen hell of brooklyn twee enamel pin fashion axe.photo booth jean shorts artisan narwhal.', + name: "anna johnson", + job: "web designer", + img: "https://www.course-api.com/images/people/person-2.jpeg", + text: "Helvetica artisan kinfolk thundercats lumbersexual blue bottle. Disrupt glossier gastropub deep v vice franzen hell of brooklyn twee enamel pin fashion axe.photo booth jean shorts artisan narwhal.", }, { id: 3, - name: 'peter jones', - job: 'intern', - img: 'https://www.course-api.com/images/people/person-4.jpeg', - text: 'Sriracha literally flexitarian irony, vape marfa unicorn. Glossier tattooed 8-bit, fixie waistcoat offal activated charcoal slow-carb marfa hell of pabst raclette post-ironic jianbing swag.', + name: "peter jones", + job: "intern", + img: "https://www.course-api.com/images/people/person-4.jpeg", + text: "Sriracha literally flexitarian irony, vape marfa unicorn. Glossier tattooed 8-bit, fixie waistcoat offal activated charcoal slow-carb marfa hell of pabst raclette post-ironic jianbing swag.", }, { id: 4, - name: 'bill anderson', - job: 'the boss', - img: 'https://www.course-api.com/images/people/person-3.jpeg', - text: 'Edison bulb put a bird on it humblebrag, marfa pok pok heirloom fashion axe cray stumptown venmo actually seitan. VHS farm-to-table schlitz, edison bulb pop-up 3 wolf moon tote bag street art shabby chic. ', + name: "bill anderson", + job: "the boss", + img: "https://www.course-api.com/images/people/person-3.jpeg", + text: "Edison bulb put a bird on it humblebrag, marfa pok pok heirloom fashion axe cray stumptown venmo actually seitan. VHS farm-to-table schlitz, edison bulb pop-up 3 wolf moon tote bag street art shabby chic. ", }, + // { + // id: 5, + // name: "anirudh negi", + // job: "engineer", + // img: "https://www.course-api.com/images/people/person-10.jpeg", + // text: "Edison bulb put a bird on it humblebrag, marfa pok pok heirloom fashion axe cray stumptown venmo actually seitan. VHS farm-to-table schlitz, edison bulb pop-up 3 wolf moon tote bag street art shabby chic. ", + // }, ]; // select items -const img = document.getElementById('person-img'); -const author = document.getElementById('author'); -const job = document.getElementById('job'); -const info = document.getElementById('info'); +const img = document.getElementById("person-img"); +const author = document.getElementById("author"); +const job = document.getElementById("job"); +const info = document.getElementById("info"); -const prevBtn = document.querySelector('.prev-btn'); -const nextBtn = document.querySelector('.next-btn'); -const randomBtn = document.querySelector('.random-btn'); +const prevBtn = document.querySelector(".prev-btn"); +const nextBtn = document.querySelector(".next-btn"); +const randomBtn = document.querySelector(".random-btn"); // set starting item let currentItem = 0; // load initial item -window.addEventListener('DOMContentLoaded', function () { +window.addEventListener("DOMContentLoaded", function () { const item = reviews[currentItem]; img.src = item.img; author.textContent = item.name; @@ -60,7 +67,7 @@ function showPerson(person) { info.textContent = item.text; } // show next person -nextBtn.addEventListener('click', function () { +nextBtn.addEventListener("click", function () { currentItem++; if (currentItem > reviews.length - 1) { currentItem = 0; @@ -68,7 +75,7 @@ nextBtn.addEventListener('click', function () { showPerson(currentItem); }); // show prev person -prevBtn.addEventListener('click', function () { +prevBtn.addEventListener("click", function () { currentItem--; if (currentItem < 0) { currentItem = reviews.length - 1; @@ -76,8 +83,8 @@ prevBtn.addEventListener('click', function () { showPerson(currentItem); }); // show random person -randomBtn.addEventListener('click', function () { - console.log('hello'); +randomBtn.addEventListener("click", function () { + console.log("hello"); currentItem = Math.floor(Math.random() * reviews.length); showPerson(currentItem);