A game that lets players to play with software development is a great way to teach programming and coding concepts such as loops and conditional statements. Zachtronics Shenzhen I/O is one game that does this. It puts players in the shoes angry engineers who work for a drab company and must build computer chips by hand. They are given increasingly complex circuits to create, starting with making lights flash in a certain pattern.
The interface of the game looks very similar to the developer tools found in browsers and teaches scripting. Screeps is a different excellent example that is a game that combines JavaScript code with massively multi-player online gameplay in order to create self sustaining colonies. Both games do a great job of teaching the basics while slowly introduce new ones.
https://mrworkspace.nl/2015/08/03/techedge-2011-presentations-and-videos/