· Travis Rodgers · Programming  · 3 min read

Spark A Child's Interest In Coding With This Silly Program

I keep hearing stories about kids learning to code and it really puzzles me. Maybe because I could not see myself doing it as a pre-teen/teenager (which of course is NOT a good way to gauge things). Perhaps it was because I did not know anyone who coded nor did anyone introduce me to it. Perhaps it was because computers were not as normative as they are now, I mean, it wasn't until high school that I even used the internet (i'm 35)?

Whatever the case, I seem to have a hard time imagining my 8-year-old daughter getting into strings or functions or arrays, etc.,

But then….

But then there are a few books I have come across recently, in particular JavaScript for Kids: A Playful Introduction to Programming, that have revved up the cognitive cogwheels. For some reason I feel like this book would have appealed to me if I were young again. And to be honest, I find it a refreshing book even now, especially with all of the practical things you build in it.

The Test

Well, just to test the interest, I decided to try something out on my daughter.

I created a simple and silly prompt/alert program in JavaScript called Travis's Truth Machine. Basically, you click the button and it asks you for a name. If the name happens to be any one of my four children, or my wife, it gives a funny answer such as, "Your name means Dirty Frog" or for me it is "Your name is the best ever."

The Response

I let them see it and it was a hit! It was the craze for the day. There just may be some truth to kids and coding, especially if there is a practical benefit (even though it was a silly game).

Try it out with your kids. It's very basic, yet it just may be that spark that directs them toward an interest in coding.

Here is the JavaScript code I created, adding some simple HTML so I could make it look a tad more appealing. I changed some of the names and alerts, so customize them accordingly:

<html>
  <body>
    <h2>Travis's Truth Machine<h2>
    <h4><em>I will tell you the truth about your name!</em></h4>
    
    <button onclick="nameGame()">Click for the truth</button>

  <script>
    function nameGame() {
    var name = prompt("Hello, what is your name?");
    if(name == "Travis"){
      alert("Awesome name");
    }else if(name == "Jenny"){
      alert("Your name means Smelly Frog");
    }else if(name == "Ben"){
      alert("Your name is Weird");
    }else if(name == "Timothy"){
      alert("Your name means Swinging Monkey");
    }else if(name == "Suzie"){
      alert("Wonderful name!");
    }else if(name == "Bobby"){
      alert("Your name means Wet Dog");
    }else if(name == "Kate"){
      alert("Your name smells like garlic");
    }else{
      alert("Your name is boring");
  }
}		
  </script>

  </body>
</html>

Add some CSS. Let your kids see you add more to it and make changes.

I hope they will find something like this as interesting as mine found it.

Happy coding!

What are your experiences with children and coding? I would love to hear in the comments below.

    Share:

    Related Posts

    View All Posts »
    5 Steps to Learn React in 2025

    5 Steps to Learn React in 2025

    React is one of the most popular front-end JavaScript libraries. Let's break down the essential steps to learn React in 2025.

    5 Reasons Laravel is Trending in 2024

    5 Reasons Laravel is Trending in 2024

    In this article, I want to give 5 reasons why I think many more people are finding a newfound enjoyment or a re-found enjoyment in the Laravel ecosystem.