Learn Basic String and Array Methods by Building a Music Player - Step 54

I’m stuck here. That’s the code I’ve tried. Doesn’t work.

const setPlayerDisplay = () => {
  playingSong = document.getElementById(`#player-song-title`);
  songArtist = document.getElementById(`#player-song-artist`);
  
};

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-basic-string-and-array-methods-by-building-a-music-player/step-54

Hi! Take in consideration this three things:

  1. playingSong and songArtist are both variables, so you should instance them with const, like: const playingSong = …
  2. Is not necessary to use backticks inside the getElementById, you can use normal quotation marks.
  3. You must give the id without the “#” symbol to the getElementById function, like: document.getElementById(“idName”). This is because is already known that is a id because you are using getElementById and not a querySelector.

Hopes it helps! :grin:

1 Like

That’s the version I tried before this one.
Tbh I have no idea why it didn’t work, but now it do after I restart my computer. Weird.
Thank you anw!

2 Likes

My code is like that:
const setPlayerDisplay = () => {
const playinSong = document.getElementById(‘player-song-title’);
const songArtist = document.getElementById(‘player-song-artist’);
};
and return that:
// running tests You should assign the

#player-song-title

element to the variable

playingSong

. Don’t forget to use

const

I think it’s a bug, but I’ m not sure.
Thank you.