Step 43 asks you to pass userData?.songs[0].id as an argument to playSong. I don’t think that optional chaining is a good thing to do here, because the function playSong assumes that a song id is passed to it and has no handling in case something else is passed. I feel that any handling of the edge case where the .songs property doesn’t exist should happen in the callback function to the playButton’s event Listener.
This step might accidentally teach more inexperienced learners to spam optional chaining even where it doesn’t make sense or might even make debugging more difficult.
Same with Step 44 - the else block is designed on the assumption that .currentSong property exists, but the step requires userData?.currentSong.id to pass. This looks wrong to me.
Thanks for the reply
I agree that with your view that there are a lot of places in this project where optional chaining isn’t really needed. I don’t think I have anything new to add to the topic though. Addressing this will need quite a few big changes to the curriculum.
You’re right, other types of chaining are helpful. But sometimes it is overused when simpler logic would suffice. Changing the curriculum to address this issue would certainly be a big deal. But it’s worth considering cleaner code and better learning outcomes. Thank you for your understanding on this topic!