Tell us what’s happening:
The instructions for this step are misleading. The introduction of the .sort() method implies that using .sort() without any parameters is always incorrect, and that the baseline should always be .sort((a, b) => a - b) and then adding any modifiers from there. Using that logic, the solution that seems to be required looks something like this:
const shuffle = () => {
userData?.songs.sort((a, b) => a - b + Math.random() - 0.5)
};
where the actual solution requires that you do not specify parameters like this.
const shuffle = () => {
userData?.songs.sort(() => Math.random() - 0.5)
};
I think delaying the information about specifying parameters for the sort method to a later step would help clear up any confusion.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 OPR/105.0.0.0
Challenge Information:
Learn Basic String and Array Methods by Building a Music Player - Step 62