Build a Music Player - Step 36

Tell us what’s happening:

I have no idea if I am formatting anything right in this step. I am not passing the 2nd test, and need help understanding. thanks :slight_smile:

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const highlightCurrentSong = () => {
  
 const songs = document.querySelectorAll(".playlist-song");
  const ariaCurrent = songs.querySelector('aria-current="true"')
  if(ariaCurrent){
    ariaCurrent.removeAttribute("aria-current")
  }
  
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0

Challenge Information:

Build a Music Player - Step 36

songs is not an element, because querySelectorAll returns an array-like structure

also you don’t need to select again the .playlist-song elements, as it is already done on line 1

also there is an other issue, querySelector checks the elements inside the element you are using it on, so you need to use a different logic to check if a .playlist-song element also has aria-current set to true

Ok. so I use playlistSongs instead of calling songs is what you are saying? If that is the case I am still confused on what syntax I should use.

 if(playlistSongs === 'aria-current="true"'){
    playListSongs.removeAttribute("aria-current")
  }

this is what I updated to but I am still not passing test 2

What is the requirement of test 2?

Double check the related User Story and ensure it’s followed precisely.

What line of code is involved?

  1. Your highlight currentSong function should use the removeAttribute method to remove the aria-current attribute from the .playlist-song element with aria-current=“true” if that element exists.

I got it thank you, I just had to use forEach! :+1:

2 Likes

let me ask you for so when i try to use forEach it return me typeerror

oh what an easy it was, although i tried more and more to use forEach and filter methods but i faild, but you encourage me and now i succeed i donno how haha :slight_smile:

please create your own topic for your questions

1 Like