Use a ternary operator to check if currentTitle
evaluates to a truthy value. If it does, set playingSong.textContent
to currentTitle
. Otherwise, set it to an empty string.
Then below that, use a ternary
operator to check if currentArtist
is truthy. If so, set songArtist.textContent
to currentArtist
. Otherwise, set it to empty string.
const playingSong = document.getElementById("player-song-title");
const songArtist = document.getElementById("player-song-artist");
const currentTitle = userData?.currentSong?.title;
const currentArtist = userData?.currentSong?.artist;
currentTitle ? currentTitle = playingSong.textContent : "";
currentArtist ? currentArtist = songArtist.textContent : "";
Can someone please help me about this code Iām very stuck here