I run Hack Club (https://hackclub.com), a nonprofit where lots of high schoolers learn to code and build awesome projects together.
Here is how the ones who are successful do it:
1. They make small technical projects they're proud of, like this https://gabitzu3.github.io/MemeOS-v0.1/
2. They do it in a way where they make friends (ex. on the Hack Club Slack, on Discords, or by going to in-person events like https://daydream.hackclub.com which is an upcoming global game jam we're hosting)
3. They do it in a way where they go on memorable adventures (either physical - like traveling to hackathons, or intellectual - like trying to build a compiler from scratch)