Step 18 music player bug

hi, totally blind. doing the music player project. up to step 18. it is not passing. so is it a bug in the fcc editor? or my code. will paste the errors and the code and the step to the link below.

errors:

When the playButton is clicked and userData.currentSong is not null, you should call the playSong function with the id of the currently playing song.

1. When the playButton is clicked and userData.currentSong is not null, you should call the playSong function with the id of the currently playing song.
javascript:
https://www.freecodecamp.org/learn/full-stack-developer/workshop-music-player/step-18
ps: so can anyone help? is it a bug or my code? if so, then how to get it to pass? have reset the lesson a few times and done a hard refresh. so,using jaws 2025 and windows 11. so stuck. can anyone help?
thank you.
marvin.

the step works for me with the correct code

you have not shared your code so I can’t check that

hi heres my code. i am sorry, google chrome crashed and thought i had pasted my script. so here it is. using jaws 2025 and windows 11 pro. marvin.

ps: pasting below.

// Step 1 & 2: Access HTML elements
const playlistSongs = document.getElementById("playlist-songs");
const playButton = document.getElementById("play");
const pauseButton = document.getElementById("pause");
const nextButton = document.getElementById("next");
const previousButton = document.getElementById("previous");

// Step 3 & 4: Define the playlist
const allSongs = [
  {
    id: 0,
    title: "Scratching The Surface",
    artist: "Quincy Larson",
    duration: "4:25",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/scratching-the-surface.mp3",
  },
  {
    id: 1,
    title: "Can't Stay Down",
    artist: "Quincy Larson",
    duration: "4:15",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/cant-stay-down.mp3",
  },
  {
    id: 2,
    title: "Still Learning",
    artist: "Quincy Larson",
    duration: "3:51",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/still-learning.mp3",
  },
];

// Step 5: Create the audio element
let audio = new Audio();

// Step 9: Create userData object
let userData = {
  songs: allSongs,
  currentSong: null,
  songCurrentTime: 0,
};

// Steps 10–15: playSong function
function playSong(id) {
  const song = userData.songs.find((song) => song.id === id);

  if (song) {
    if (userData.currentSong === null || userData.currentSong.id !== song.id) {
      audio.src = song.src;
      audio.title = song.title;
      audio.currentTime = 0;
      userData.songCurrentTime = 0;
      userData.currentSong = song;
    } else {
      audio.currentTime = userData.songCurrentTime;
    }

    playButton.classList.add("playing");
    audio.play();
  }
}

// Steps 16–18: Play button functionality
playButton.addEventListener("click", () => {
  if (userData.currentSong === null) {
    playSong(userData.songs[0].id);
  } else {
    playSong(userData.currentSong.id);
  }
});


The issue is not with your code for this step, which is correct.

The reason this step is not passing is because you’ve lost some of the song data from the allSongs variable. You only have three songs in there, when you should have 10. If you restore the missing objects, your code passes for me.

You could Reset the step and then paste your code for this step again or, if it helps, here is the correct allSongs array, containing all the required data:

const allSongs = [
  {
    id: 0,
    title: "Scratching The Surface",
    artist: "Quincy Larson",
    duration: "4:25",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/scratching-the-surface.mp3",
  },
  {
    id: 1,
    title: "Can't Stay Down",
    artist: "Quincy Larson",
    duration: "4:15",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/cant-stay-down.mp3",
  },
  {
    id: 2,
    title: "Still Learning",
    artist: "Quincy Larson",
    duration: "3:51",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/still-learning.mp3",
  },
  {
    id: 3,
    title: "Cruising for a Musing",
    artist: "Quincy Larson",
    duration: "3:34",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/cruising-for-a-musing.mp3",
  },
  {
    id: 4,
    title: "Never Not Favored",
    artist: "Quincy Larson",
    duration: "3:35",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/never-not-favored.mp3",
  },
  {
    id: 5,
    title: "From the Ground Up",
    artist: "Quincy Larson",
    duration: "3:12",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/from-the-ground-up.mp3",
  },
  {
    id: 6,
    title: "Walking on Air",
    artist: "Quincy Larson",
    duration: "3:25",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/walking-on-air.mp3",
  },
  {
    id: 7,
    title: "Can't Stop Me. Can't Even Slow Me Down.",
    artist: "Quincy Larson",
    duration: "3:52",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/cant-stop-me-cant-even-slow-me-down.mp3",
  },
  {
    id: 8,
    title: "The Surest Way Out is Through",
    artist: "Quincy Larson",
    duration: "3:10",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/the-surest-way-out-is-through.mp3",
  },
  {
    id: 9,
    title: "Chasing That Feeling",
    artist: "Quincy Larson",
    duration: "2:43",
    src: "https://cdn.freecodecamp.org/curriculum/js-music-player/chasing-that-feeling.mp3",
  },
];

When doing a step, it is critically important that you use the seed code given for each step and make no extra changes.