Day 34 at Makers Academy

Bowling

As I finished the Thermostat yesterday and tomorrow is a Bank Holiday, today I started work on the Friday Challenge.

Bowling Score Card

The challenge was to create a program in JavaScript that allowed you to track the score in a game of bowling. In the morning I managed to get it working to a decent point. You can start a game, bowl for 10 frames, get an extra bowl in frame 10 if you get a strike or a spare, and strikes and spares are counted properly. The only thing I didn’t have working was actually scoring it properly.

In bowling, if you get a strike, you get 10 points, plus the combined score of your next two bowls. At this point all the bowls were being stored in an array, I just had to figure out a way to add this up properly. Here is how it works at the moment though:

Wherever I type ‘bowl’ it shows the current status of my variables. You can see this changes depending on which bowl I am on and which frame

As I had so many variables going on, it led to some errors which were hard to track. Because of this I added console.log() to pretty much every part of the program, to see what bits were being run. This really helped me solve a problem where my score was being added twice:

The numbers after every command shows the path through my code and allows me to identify where potential errors are.

I have managed to get it scoring a perfect game as 300, so thats a start, the rest is proving difficult though!

Weather

Today was also the first (and maybe last) day we had really nice weather this year, so I made the most of it and went up onto the Makers terrace for some of the afternoon, which was lovely! There was also a dog up there, which made it even better!

Code on the Ceiling – The Mac Keys


Todays song of the day:

Leave a comment