Hi guys, as I promised…my “not-so-pro” reviews on the book I’m reading;
“Eloquent Javascript” by Marijn Haverbeke.
Chapter 4 talked about Data structures: Objects and Arrays.From arrays to properties(like propName.length) to methods(eg propName.push for arrays) to Objects proper(the different types) et al.
Complex at first,but at the third read,I started to see a rray of what it was about and I was able to understand and also solve some problems in the exercise. Working on the exercises in this chapter taught me to always go back,revise & re-strategize each time I encountered an issue/challenge and to never give up (also due to the fact that Ollaollu and Lekan were away(sort of) but,well..you feel me? yeah).I think I’m pretty grounded in this part of JavaScript(so help me …..Brendan… Eich?).
Well this was one of the questions:
The Sum of a Range
Write a range function that takes two arguments, start and end, and returns an array containing all the numbers from start up to (and including) end. Next, write a sum function that takes an array of numbers and returns the sum of these numbers. Run the previous program and see whether it does indeed return 55. As a bonus assignment, modify your range function to take an optional third argument that indicates the “step” value used to build up the array. If no step is given, the array elements go up by increments of one, corresponding to the old behavior. The function call range(1, 10, 2) should return [1, 3, 5, 7, 9]. Make sure it also works with negative step values so that range(5, 2, -1) produces [5, 4, 3, 2].
Piece of cake,right? I know too.
JavaScript to me anytime I try to run a wrong code;
*At this point,I go back to Viking for more action on Objects/arrays(Or basically all I’ve learnt on JavaScript) as it’s one of the things that keep me going(yes,(Sometimes?) I love challenges) and discovered I have some assignment to test me on all what I’ve been talking about(from chapter one to this point).
**Heart starts racing**
**Big grin**
**Rubs hands** (like Birdman)
Well,It was kind of challenging at first but with each code I wrote I became more confident..you can check it out here (plus I also built a roulette game using basic OOP, here).
“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies” — C.A.R. Hoare, 1980 ACM Turing Aware Lecture.
Random picture from twitter
Finally I’m done with the basics.
Nobody saw what I did up there? smh,you people don’t deserve me.
*No be so them dey do something my guy*- Nigerian pidgin English for “that’s not the right way of doing things”.