One of the best ways to learn to write code is through an online course that teaches you how to write JavaScript with an instructor that will explain the code, what versions you should use, and why. Learning to develop a real-world application, with an instructor explaining in a step-by-step fashion, will teach you modern code techniques.