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:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

<html>

<body>

<h2>Travis'sTruth Machine<h2>

<h4><em>Iwill tell you the truth about your name!</em></h4>

<button onclick="nameGame()">Clickforthetruth</button>

<script>

functionnameGame(){

varname=prompt("Hello, what is your name?");

if(name=="Travis"){

alert("Awesome name");

}elseif(name=="Jenny"){

alert("Your name means Smelly Frog");

}elseif(name=="Ben"){

alert("Your name is Weird");

}elseif(name=="Timothy"){

alert("Your name means Swinging Monkey");

}elseif(name=="Suzie"){

alert("Wonderful name!");

}elseif(name=="Bobby"){

alert("Your name means Wet Dog");

}elseif(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.