An excellent plan! If you really want to make sure you’ve understood something, write down an explanation of it. There’s nothing quite like writing to really test your grasp of an idea. Even if nobody else ever reads it, it’s still an extremely valuable exercise for yourself.
Math.round(Math.random() * (array.length - 1))
It might seem like a small thing, but look what you have to understand:
- How Math.round works (pretty straightforward — it rounds a floating point number to the nearest whole number).
- How Math.random works (less straightforward — it gives a random number between zero and one, meaning you have to multiply it to do anything useful with the result).
- How array.length works (seems straightforward — it gives you the total number of items in an array, but then catches you out when you realise there can never be an index with that total value because the indices are counted from zero …which gives rise to an entire class of programming error).
I really like this approach to learning: document each small thing as you go instead of waiting until all those individual pieces click together. That’s the approach Andy took when he was learning CSS and it led to him writing a book on the subject.
Graham has been raving about the You Don’t Know JS book series by the supersmart Kyle Simpson. I suggested to Charlotte that we read through the books at the rate of one chapter a week. The first book is called Up and Going and our first chapter will be Into Programming, starting this week. Then at the end of the week we’ll get together to compare notes.
I’m hoping that by doing this together, there’s more chance that we’ll actually see it through to completion:
Why can I hit deadlines imposed by others, but not those imposed by myself?
This was originally posted on my own site.