It is best to learn a thing is to do the thing.
When learning a new skill or topic, it’s best to go right at the thing. Transfer of knowledge from, say, lessons heard in a lecture to real world situations are actually way less common than anyone in academia would want to believe. The best way to learn a thing is to do the thing. This provides the most direct feedback, ensures the lessons learned are actually applicable, and doesn’t lull you into a false sense of progress. Also - you’re essentially guaranteed to run into real-world stumbling blocks that don’t make themselves present in the “clean” learning environment. The spherical chicken in a vacuum doesn’t exist. Your Spanish homework doesn’t teach you the necessary skill to recall similar words or think of different things you could say rather than the word you forgot, or look up things quickly in an English-to-Spanish dictionary.
The further removed your learning tasks are from the application you have in mind, the less likely they are to transfer to said application.
Your score in Duolingo might be high, but can you speak to someone? Does watching someone write code actually teach you how to do it?