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

Tell us what’s happening:

I dont understand what i am to do. How do i use the ternary operator to check if currentTitle is truthy?

Your code so far

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

/* file: styles.css */

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

  currentTitle ? playingSong.textContent = currentTitle : "";

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

Challenge Information:

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

I would suggest resetting the lesson.

The first issue is your left hand side of the assignment oeprator

you should only have the element name followed by textContent and nothing else.

Here is the exaple they gave again

element.textContent

the goal is to update the elements text content

once you fix that, then you will need to fix your ternary here

here is the correct syntax for a ternary

someCondition ? doSomethingIfTrue : doSomethingElseIfConditionFalse

the right hand side of the assignment operator needs to use that correct syntax

as for the condition, you want to check if currentTitle is truthy

truthy values in javascript are coerced to true in a boolean context like an if/else statemnt or ternary like this

the logic for this step is to say if there is a currentTitle, then show that current title. Otherwise show and empty string. Same logic goes for the currentArtist.

Here is another example of checking if something is truthy or not

let isOldEnoughToVote = true

isOldEnoughToVote ? "You should vote in the next election" : "You are not old enough to vote"

hope that helps

1 Like