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

Tell us what’s happening:

I’m going crazy trying everything to figure this out. I looked up the ternary operator on MDN and still can’t tackle it. Please help me understand my mistake.

Your code so far

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

/* file: styles.css */

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

  playingSong.textContent ? (currentTitle : "");
  songArtist.textContent ? (currentArtist : "");

// 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/124.0.0.0 Safari/537.36

Challenge Information:

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

A ternary expression is something like the following:

let cost = isMember ? '$2.00' : '$10.00'

It’s an if/else statement that evaluates to two different values condescended all the way down to one line. The value for that ternary expression is then stored into a variable.

Hope this helps.

1 Like

Here you go @jfo0707
playingSong.textContent = currentTitle ? currentTitle : “”
songArtist.textContent = currentArtist ? currentArtist : “”

2 Likes