Skip to main content

"Stop Teaching Code" in JavaScript

At some time in the future, I would like to return to the classroom to teach programming to middle school students. That is the age when I first starting coding, and I would love the opportunity to inspire the next generation of developers at an early age.

So I’m on the lookout for good techniques, strategies, and patterns for teaching the basics of computer science. Hit me up if you have any.

Today I read “Stop Teaching Code” by Jeff Olson where he described a different approach to teaching programming. He advocated for ditching the definitions, unrealistic examples, and non-sensical names and use real-world puzzles for students to solve.

It’s an interesting read, and I recommend it if you have any dreams of teaching programming.

All of the examples in Olson’s article are in Python, but I plan on introducing students to code with JavaScript. So here are all of the examples from his article rewritten in JavaScript:

Translated Examples

Note: I’ve linked to the nearest anchor on Medium, but they appear to be generated and might change. Your mileage may vary.

1. Code for Predictions

let name = "Tamara"

console.log("Hello" + name)

2. Example 1: Conditionals

let age = 15

if (age >= 18) {
    console.log("You're old enough to buy a ticket for an R-rated film.")
} else {
    console.log(`You'll be old enough in ${18 - age} years`)

3. Example 2: Collections

let favorite_foods = ["Sushi", "Tamales", "Mofongo", "Pizza", "Chicken Tikka"]


3. Example 3: Objects

let user1 = User("Ty", "", 16, "Pa$$word")
let user2 = User("Sarai", "", 15, "Kangaroo!")
let user3 = User("Osu", "", 12, "12345abcde")


I hope that helps. Happy coding!