Home > OS >  Javascript project wont cycle through array list
Javascript project wont cycle through array list

Time:07-26

currently practicing with a javascript project where a person would be able to cycle through a few profiles that have been set up in an array. From what i can see my code is correct but when I go to the console I receive multiple uncaught errors and Im not sure how to fix what i need to fix for it to transition through each one the way I want. I have attached my code

//local data
const goats = [
    {
        id:1, 
        player: "Lebron James",
        position: "SF",
        img: "https://www.google.com/search?q=lebron james&rlz=1C5CHFA_enUS854US866&sxsrf=ALiCzsYNGc8IjrKMKJxcHRFPNhMhfW3LuQ:1658756349865&tbm=isch&source=iu&ictx=1&vet=1&fir=lSggYxaBapjIUM%2Cz-ZwiWHhXouBBM%2C_%3B4fGW2sEjnd8q1M%2CQy9Jh9pYLr__TM%2C_%3BGf_LIq946ZWVMM%2CAqFKpNGYkd0JQM%2C_%3BxqLaF7pWdlPRsM%2CsSJdlzEAFQrJvM%2C_&usg=AI4_-kSn2Xh3Za950B_ne-eCha23VbkLWQ&sa=X&ved=2ahUKEwiPkYL4lJT5AhWGEGIAHfsxA_sQ_h16BAgiEAE#imgrc=4fGW2sEjnd8q1M",
        text: "4x NBA Champion, 4x MVP, 18x All-Star",
    },
    {
        id:2,
        player: "Kareem Abdul-Jabbar",
        position: "C",
        img: "https://www.google.com/search?q=kareem abdul jabbar&client=safari&rls=en&sxsrf=ALiCzsZy9Ol4hFucKlZsm3aIkM84uPppmg:1658507981371&tbm=isch&source=iu&ictx=1&vet=1&fir=n6jC4Jwu4JAg9M%2CYtVZWBsaYktD3M%2C_%3BXfISOrRzPCTGnM%2CsCRgJqzggzP-0M%2C_%3BKYZZFDaWarQtsM%2CIc_jRlXUPaKr_M%2C_%3Bd4EbvMdVRKruwM%2CJPX3SmHl2zdobM%2C_&usg=AI4_-kQ5jLwAjTEXv6jVvg3ATF79674rGQ&sa=X&ved=2ahUKEwivqtjY94z5AhVIFFkFHdLsBL4Q_h16BAglEAE#imgrc=d4EbvMdVRKruwM",
        text: "6x NBA Champion, 6x MVP, 19x All-Star",
    },
    {
        id:3,
        player: "Kobe Bryant",
        position: "SG",
        img: "https://www.google.com/search?q=kobe bryant&client=safari&rls=en&sxsrf=ALiCzsZwSZQt2iV1TRy9j3hRKqk6ZGjNUw:1658508123200&tbm=isch&source=iu&ictx=1&vet=1&fir=VI7Msn9xX9e5mM%2CTYvwsOXKOaxgXM%2C_%3Be8Ojylm8xplGLM%2CXDuPE2LrNfqFOM%2C_%3Bj22Zt04K2mGDsM%2C1WEx2wkoRouqGM%2C_%3BFMMgVzOaDwsJBM%2C3_7Nb2A2-pGJNM%2C_&usg=AI4_-kQO-g7DTHUysQihmkaLwlUiZXFRBw&sa=X&ved=2ahUKEwje8qic-Iz5AhWyM1kFHcTkCnAQ_h16BAgzEAE#imgrc=VI7Msn9xX9e5mM",
        text: "5x NBA Champion, 1x MVP, 18x All-Star",
    }
];

//select items
const img = document.getElementById("person-img");
const player = document.getElementById("player");
const position = document.getElementById("position");
const info = document.getElementById("info");

const prevBtn = document.querySelector(".prev-btn");
const nextBtn = document.querySelector(".next-btn");
const randomBtn = document.querySelector(".random-btn");


//set starting item
let currentItem = 3;

//load initial item
window.addEventListener("DOMContentLoaded", function () {
    showPerson();
});

//show person based on item

function showPerson(person){
    const item = goats[person];
    img.src = item.img;
    player.textContent = item.player;
    position.textContent = item.position;
    info.textContent = item.text;
};

//show next person

nextBtn.addEventListener('click', function(){
    currentItem  ;
    if(currentItem > goats.length - 1) {
        currentItem = 0;
    }
    showPerson();
});

nextBtn.addEventListener('click', function(){
    currentItem--;
    if(currentItem < 0) {
        currentItem = goats.length - 1;
    }
    showPerson();
});

//show random person
randomBtn.addEventListener('click', function(){
    currentItem = Math.floor(Math.random() * goats.length)
    console.log(currentItem);
    showPerson();
});
.title{
    text-align: center;
    padding-bottom: 0;
    margin-top: 0px;
    margin-bottom: 0px;

}

.underline{
    background-color: black;
    width: 8%;
    margin-left: 560px;
    height: 5px;
    margin-top: 0%
}

.review{
    border: 3px rgb(0, 0, 0) solid;
    display: block;
    padding: 9px;
    border-radius: 40px;
    width: 600px;
    margin-left: 300px;
    background-color: aliceblue;
}

.img-container{
    display: flex;
    justify-content: center;
    padding-top: 5vh;
}

.img-container img{
    border-radius: 20%;
    height: 130px;
    width: 130px;
}

#player{
    text-align: center;
}

#position{
    text-align: center;
}

#info{
    text-align: center
}

.button-container2{
    text-align: center;
}

.prev-btn{
    background-color: transparent;
    border:none;
}

.next-btn{
    background-color: transparent;
    border:none;
}

.random-btn{
    position: relative;
    left:255px;
    top: 8px;
    background-color: transparent;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="/index.css">
    <script src="https://kit.fontawesome.com/57a34a3966.js" crossorigin="anonymous"></script>
</head>
<body>
    <main>
        <section id="navbar">
                    <header>
                        <nav>
                            <ul>
                                    <li><a href="index.html">Color Flipper</a></li>
                                    <li><a href="counter.html">Counter</a></li>
                                    <li><a href="#">Project 3</a></li>
                
                
                            </ul>
                        </nav>
                    </header>
        </section>
        <section >
            <div >
                <h2>The GOATS</h2>
                <div ></div>
            </div>
            <article >
                <div >
                    <img src="mj.jpeg" id="person-img" alt="">
                </div>
                <h4 id="player">Michael Jordan</h4>
                <p id="position">SG</p>
                <p id="info">6x NBA Champion, 5x MVP, 9x All-Defensive, 14x All-Star</p>
                <div >
                    <button >
                        <i ></i>
                    </button>
                    <button >
                            <i ></i>
                        </button>
                </div>
                <button >surprise me</button>
            </article>

        </section>
    </main>
    <script src="reviews.js"></script>
</body>
</html>

CodePudding user response:

person is never defined. you have a parameter person in your method showPerson but when calling you don't pass any arguements. need to set it to currentItem which should start at 2 not 3 as arrays are 0 based

//local data
const goats = [
    {
        id:1, 
        player: "Lebron James",
        position: "SF",
        img: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUSEhIVFRUVFxUVFRcVFRUVFRYVFRUW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N6IsdZpVJvJGw9adSpUyIVeVCNKlQIVKOPJpUqBo31jYgipjWa4pUqmlwQud84GpFvADzEEQPuI1qXIaVKvmE8yfvZ14cIEeftTvWlSqBYMFOfYYpUqCXUaM0VaVKkQY5qTDalSqREh38OYZVG qORcYyTlCMAda8qRLsKVKvTf087RqL3fyZdTyjLNTQTSpV6gyhY5DWXelSoGBLUWOsUqBGQN6PSpUCZmmk0qVAgdwdqJZ2eVz60qVRm7Ikf/Z",
        text: "4x NBA Champion, 4x MVP, 18x All-Star",
    },
    {
        id:2,
        player: "Kareem Abdul-Jabbar",
        position: "C",
        img: "https://img.sharetv.com/people/standard/kareem_abdul-jabbar.jpg",
        text: "6x NBA Champion, 6x MVP, 19x All-Star",
    },
    {
        id:3,
        player: "Kobe Bryant",
        position: "SG",
        img: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUSEhIVFRUVFxUVFhUVFRYVFxUVFRUWFxUVFRUYHSggGBolHRUVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGxAQGi0lHyUtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAOEA4QMBIgACEQEDEQH/xAAcAAACAwEBAQEAAAAAAAAAAAADBAIFBgAHAQj/xABGEAABAwIDBAcEBgcGBwEAAAABAAIDBBESITEFBkFREyIyYXGBkQcUobEjQlJywfAzU2KCktHhNHODssLxFUOTorPD0mP/xAAbAQACAwEBAQAAAAAAAAAAAAACAwEEBQAGB//EADsRAAEDAgQDBQYEAwkAAAAAAAEAAhEDIQQSMUFRYYETIjJx8AUUkaGx0QYzcsFCUrIVIzRigpKiwvH/2gAMAwEAAhEDEQA/AG7hdcIHSBc6ULcVJTleLLN7Wl1VvV1OSzG1J73SapsjaLrO7SqM0TZtTmkKwZr5QvzWfeVY2W82bICrxkgssns osFaR1N1fpuEJBbJVhLMEA1IScr0N17IXVLpgai1VaFR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dvlz6IqRINrc1htr7B2hNE2rrnWZcYWGweA  eACzRkBmb5jJDoKUCwAs0Z ma9X3mgElJMzXDcj90iQf5fivNhMyPDjdhDiG34c8 7JZ3sz2g7E4R74AIJsLCCJHW58zdNrUorNaTYxcrT0LwGgDkmWm6QgFgOR8/Qp nXmXjdbyZaPza6Zp28/5ePkhMYnaWPOw7reKqvfAQOCyftWkJip4Rxc6U8shgbl5uXnlMCCtZvrX9LVSW7LPo2 DMr ZufNZhh64XvfZuH93wrGHWJPmbn4adF56tUz1CVd0EQAz1R52iyhSC6ZmhyuVdhKlZatfZyHHUo20I7ElVr5UbKhC4tlWDqhCxpJ1QgipQOJJuiAVvT2urKGQLPQTpptT3q1h6gYZSKrSVf9OF9VH7wuV73xqr 7lfoKl/SD734Lwb2j/26X/D/wDCxcuXiPw1/h3/AKj/AEsW7jfGPIfVZqXQ/ngt5N9X7rf8oXLltY/ Hqk4bUpKTX1UXcFy5UCrYSm1/wBC/wAPxCyZXLldw/hPmqdbxLgptXLlYCQiR9r L5r132Bdmt8G/J6 Lkx/g6/u1SttN2Jfuf8ArK8Z3m7Mf3j8ly5eS/DP5NT/AE/RXsb Y1afdX yt8/mr m0X1cs/G/nP/UVp0Py2 Saj4Ky2Z22 I a5csypojfovHqzU J aRg7S rl9MK8uNFodnJuo0XLlw0XBZnaioZVy5BujCWkUWrlyndcmYkZi5ci2QlHXLlyhQv/9k=",
        text: "5x NBA Champion, 1x MVP, 18x All-Star",
    }
];

//select items
const img = document.getElementById("person-img");
const player = document.getElementById("player");
const position = document.getElementById("position");
const info = document.getElementById("info");

const prevBtn = document.querySelector(".prev-btn");
const nextBtn = document.querySelector(".next-btn");
const randomBtn = document.querySelector(".random-btn");


//set starting item
let currentItem = 2;

//load initial item
window.addEventListener("DOMContentLoaded", function () {
    showPerson(currentItem);
});

//show person based on item

function showPerson(person){
    
    const item = goats[person];
    
    img.src = item.img;
    player.textContent = item.player;
    position.textContent = item.position;
    info.textContent = item.text;
};

//show next person

nextBtn.addEventListener('click', function(){
    currentItem  ;
    if(currentItem > goats.length - 1) {
        currentItem = 0;
    }
    showPerson(currentItem);
});

nextBtn.addEventListener('click', function(){
    currentItem--;
    if(currentItem < 0) {
        currentItem = goats.length - 1;
    }
    showPerson(currentItem);
});

//show random person
randomBtn.addEventListener('click', function(){
    currentItem = Math.floor(Math.random() * goats.length)
 //   console.log(currentItem);
    showPerson(currentItem);
});
.title{
    text-align: center;
    padding-bottom: 0;
    margin-top: 0px;
    margin-bottom: 0px;

}

.underline{
    background-color: black;
    width: 8%;
    margin-left: 560px;
    height: 5px;
    margin-top: 0%
}

.review{
    border: 3px rgb(0, 0, 0) solid;
    display: block;
    padding: 9px;
    border-radius: 40px;
    width: 600px;
    margin-left: 300px;
    background-color: aliceblue;
}

.img-container{
    display: flex;
    justify-content: center;
    padding-top: 5vh;
}

.img-container img{
    border-radius: 20%;
    height: 130px;
    width: 130px;
}

#player{
    text-align: center;
}

#position{
    text-align: center;
}

#info{
    text-align: center
}

.button-container2{
    text-align: center;
}

.prev-btn{
    background-color: transparent;
    border:none;
}

.next-btn{
    background-color: transparent;
    border:none;
}

.random-btn{
    position: relative;
    left:255px;
    top: 8px;
    background-color: transparent;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="/index.css">
    <script src="https://kit.fontawesome.com/57a34a3966.js" crossorigin="anonymous"></script>
</head>
<body>
    <main>
        <section id="navbar">
                    <header>
                        <nav>
                            <ul>
                                    <li><a href="index.html">Color Flipper</a></li>
                                    <li><a href="counter.html">Counter</a></li>
                                    <li><a href="#">Project 3</a></li>
                
                
                            </ul>
                        </nav>
                    </header>
        </section>
        <section >
            <div >
                <h2>The GOATS</h2>
                <div ></div>
            </div>
            <article >
                <div >
                    <img src="mj.jpeg" id="person-img" alt="">
                </div>
                <h4 id="player">Michael Jordan</h4>
                <p id="position">SG</p>
                <p id="info">6x NBA Champion, 5x MVP, 9x All-Defensive, 14x All-Star</p>
                <div >
                    <button >
                        <i ></i>
                    </button>
                    <button >
                            <i ></i>
                        </button>
                </div>
                <button >surprise me</button>
            </article>

        </section>
    </main>
    <script src="reviews.js"></script>
</body>
</html>

CodePudding user response:

Your showPerson function should not take an argument. It should just use the currentItem variable that you are modifying with the buttons.

function showPerson() {
  const item = goats[currentItem]; // <-- Access the global index
  // ...

Also, you did not add the listener to the previous button. The decrement of currentItem should be attached to the prevBtn. Also, I would rename currentItem with currentIndex, because it represents an index.

prevBtn.addEventListener('click', function() {
  currentItem--;
  // ...

Speaking of indices, your variable should be zero-indexed. Arrays are indexed at zero.

let currentItem = 2; // Item #3 (or index 2)

Working example

// Local data
const goats = [{
  id: 0,
  player: "Michael Jordan",
  position: "SG",
  img: "https://google.com/search?tbm=isch&q=michael jordan",
  text: "6x NBA Champion, 5x MVP, 14x All-Star",
}, {
  id: 1,
  player: "Lebron James",
  position: "SF",
  img: "https://google.com/search?tbm=isch&q=lebron james",
  text: "4x NBA Champion, 4x MVP, 18x All-Star",
}, {
  id: 2,
  player: "Kareem Abdul-Jabbar",
  position: "C",
  img: "https://google.com/search?tbm=isch&q=kareem abdul jabbar",
  text: "6x NBA Champion, 6x MVP, 19x All-Star",
}, {
  id: 3,
  player: "Kobe Bryant",
  position: "SG",
  img: "https://google.com/search?tbm=isch&q=kobe bryant",
  text: "5x NBA Champion, 1x MVP, 18x All-Star",
}];

//select items
const img = document.getElementById("person-img");
const player = document.getElementById("player");
const position = document.getElementById("position");
const info = document.getElementById("info");

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() {
  showPerson();
});

// Show person based on item
function showPerson() {
  const item = goats[currentItem];
  img.src = item.img;
  player.textContent = item.player;
  position.textContent = item.position;
  info.textContent = item.text;
};

// Show next person
nextBtn.addEventListener('click', function() {
  currentItem  ;
  if (currentItem > goats.length - 1) {
    currentItem = 0;
  }
  showPerson();
});

// Show prev person
prevBtn.addEventListener('click', function() {
  currentItem--;
  if (currentItem < 0) {
    currentItem = goats.length - 1;
  }
  showPerson();
});

// Show random person
randomBtn.addEventListener('click', function() {
  currentItem = Math.floor(Math.random() * goats.length)
  console.log(currentItem);
  showPerson();
});
button {
  cursor: pointer;
}

.title {
  text-align: center;
  padding-bottom: 0;
  margin-top: 0px;
  margin-bottom: 0px;
}

.underline {
  background-color: black;
  width: 8%;
  margin-left: 560px;
  height: 5px;
  margin-top: 0%
}

.review {
  border: 3px rgb(0, 0, 0) solid;
  display: block;
  padding: 9px;
  border-radius: 40px;
  width: 600px;
  margin-left: 300px;
  background-color: aliceblue;
}

.img-container {
  display: flex;
  justify-content: center;
  padding-top: 5vh;
}

.img-container img {
  border-radius: 20%;
  height: 130px;
  width: 130px;
}

#player,
#position,
#info {
  text-align: center
}

.button-container2 {
  text-align: center;
}

.prev-btn,
.next-btn {
  background-color: transparent;
  border: none;
}

.random-btn {
  position: relative;
  left: 255px;
  top: 8px;
  background-color: transparent;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="/index.css">
  <script src="https://kit.fontawesome.com/57a34a3966.js" crossorigin="anonymous"></script>
</head>
<body>
  <main>
    <section id="navbar">
      <header>
        <nav>
          <ul>
            <li><a href="index.html">Color Flipper</a></li>
            <li><a href="counter.html">Counter</a></li>
            <li><a href="#">Project 3</a></li>
          </ul>
        </nav>
      </header>
    </section>
    <section >
      <div >
        <h2>The GOATS</h2>
        <div ></div>
      </div>
      <article >
        <div >
          <img src="" id="person-img" alt="">
        </div>
        <h4 id="player">PLAYER</h4>
        <p id="position">POSITION</p>
        <p id="info">INFO</p>
        <div >
          <button >
            <i ></i>
          </button>
          <button >
            <i ></i>
          </button>
        </div>
        <button >surprise me</button>
      </article>
    </section>
  </main>
  <script src="reviews.js"></script>
</body>
</html>

  • Related