Learn Basic String and Array Methods by Building a Music Player

Tell us what’s happening:

My code so far is doing well but I am just curious what is the “user.Data?.currentSong” thing. This question may sound weird but I really need someone to explain… :smiley:

Your code so far


The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

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

what is it that you do not understand of this?

Like is the code refering to

const audio = new Audio();
let userData = {
songs: […allSongs],
currentSong: null,
songCurrentTime: 0,

this code?

And also may I know how the ?. works in the code that I just mentioned

if the dot in user.Data is a typo, then yes it is probable that it is referring to that.

The ? in this case is called optional chaining, if something in the chain is null or undefined, the whole chain evaluates to undefined instead of throwing an error

More infos here: Optional Chaining in JavaScript – Explained with Examples

1 Like