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

  • by:
  • 3 minutes read

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:

    <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>

    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");
      alert("Your name is boring");


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.


** This article may contain affiliate links. Please read the affiliate disclaimer for more details.