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

The help prompt says to call the playSong function with userData?.song[0].id inside your if block.
This is what I thought I did. I tried return along with it too to no avail. Where did I go wrong?

Your code so far

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

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

if (userData?.currentSong === null) {
  playsong(userData?.songs[0].id)
}

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15

Challenge Information:

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

And of course I just noticed my mistake after posting this but I can’t delete the original post.

this if does not fulfill the requirements which were:

add an if to check if userData?.currentSong is falsey .

To check if something is falsey you need to use the NOT operator which looks like an exclamation mark !
for eg.

if (!myVariable) {
  console.log("myVariable was false");
}

This code will check if myVariable is a falsey and will log the statement shown if so.

Also you have a typo here:

it should be playSong not playsong

if (userData?.currentSong === null) {
 }

The lesson did accept the use of null in the beginning of the statement once I fixed my capitalization error. Should null not be used irl to check if something is falsey?

Yes I am aware that the lesson is accepting this but to check if something is a falsey you should be checking for more than null values. For eg a zero is a falsey. So is an empty string. So is undefined.

1 Like