I disagree. You should write as much code as possible, run into as many problems as possible, and solve them. This is how you actually learn how to program. Feel free to play with and adapt other people's code along the way though.
> There is excellent code out there.
Sure, there may be "excellent code" out there by some standard, but nobody can agree on what "good code" is. Your application of "clean code" and "design patterns" might be considered overengineered enterprise junk. Your side-effect-free generalized functional code might be considered obtuse and academic. Your straight-and-to-the-point procedural code might be considered inelegant or "not modular enough". People have way too many strong opinions on this subject and they can't all be taken seriously.
Also, a lot of "excellent code" out there is written in older language versions, full of workarounds for problems that don't exist anymore. This is particularly important for Javascript or C++. The difference is is like night and day.