Sunday, March 03, 2019

Exercises for Programmers: 57 Challenges to Develop Your Coding Skills - Chapter 3, Pizza Slices, Version 2

The second version of the pizza exercise was about changing the formula.  It was only a bit of math.  I was confused because my Math. functions weren't working right.  But it had nothing to do with Math.  It was all about my lack of a return keyword and some bad parens.  I've become better at sussing those out - fewer initial assumptions on my part.

JSFiddle: https://jsfiddle.net/NodToNothing/pz3Lhu2m/

The math is a bit more difficult to work out mentally than the other pizza exercise.  I almost had to write it down to make sure it was right.  I didn't do the part with use "piece" or "pieces" depending on 0, 1, many.  That seems like busywork.


The Vue.js code:

 

No comments: