In ICS 314 we have “Workout of the Day” coding exercises which are shortened to WODs. Although there were practice WODs before the first official WOD conducted in class, the main focus of this essay is about the BertErnie WOD.
The first two practice WODs were relatively easy, looking back on them now, they were extremely easy. The main difficulty was how JavaScript differed from Java, meaning I spent some time researching the specifics of JavaScript to make sure I followed the correct syntax. These practices helped well in preparation for the actual BernErnie WOD, the same goes with the experience in quickly searching for the proper topics about what I want to program.
The WOD BertErnie is an algorithm that prints out Strings of the numbers 1 to 100 but will print out Bert for numbers divisible by 4, Ernie for numbers divisible by 6, and BertErnie for numbers divisible by both.
I won’t be including my implementation of BertErnie, but I went for the obvious approach of using chain If and Else if statements to account for each requirement. I thought about using a switch statement or a ternary operator, but due to the time pressure, I decided to stick to what I was comfortable with.
Right after completing the WOD, we had a class discussion to discuss the different ways to accomplish the same task. These types of discussions are extremely valuable as you can be exposed to different program structures. A particular challenge posed was to complete the same WOD without using a loop. What I didn’t expect was the use of recursion to loop through 1 to 100. Although I believe the recursions are considered loops, I feel a little cheated.