Tell us what’s happening:
This is my code:
const names sortSongs(userData?.songs) {
}
Is someone able to advise me as to where I am going wrong?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const names sortSongs(userData?.songs) {
}
// 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/127.0.0.0 Safari/537.36 Edg/127.0.0.0
Challenge Information:
Learn Basic String and Array Methods by Building a Music Player - Step 28
Hello @fitzgeraldp !
Good attempt.
Here are the instructions for this step.
Inside your sortSongs function, add the sort() method to userData?.songs.
Is it asking us to add the sort() function method to userData?.songs
We should not add the names to this code.
I hope this helps you.
Wishing you good progress on your coding journey.
Thanks. Are you able to expand any further as I have tried messing around with code to no success? Thanking you
Tell us what’s happening:
Hello,
This is my updated code:
function sortSongs(userData) {
userData?.songs?.sort();
}
Not sure where I am going wrong. Can someone please help? Thanking you.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function sortSongs(userData) {
userData?.songs?.sort();
}
// 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/127.0.0.0 Safari/537.36 Edg/127.0.0.0
Challenge Information:
Learn Basic String and Array Methods by Building a Music Player - Step 28
hbar1st
September 5, 2024, 10:10pm
5
The sort function is not called with ?. notation. That notation is for accessing a key in the object. Sort is a method so you just call it normally with plain old dot notation.
hbar1st
September 5, 2024, 10:21pm
6
I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.
Thanks.
lasjorg
September 5, 2024, 10:40pm
7
As said, it didn’t ask you to use optional chaining on the songs
property. Not that it would matter, except the test doesn’t expect it.
It also didn’t ask you to add a parameter to sortSongs
. Here the test doesn’t care, but just know, anytime you add something that wasn’t asked for, the tests may fail.
Sorry! I was not on to respond to your question.
Glad to hear you got it worked out.
Wishing you good progress on your coding journey, @fitzgeraldp !