My orthodontist appointment today was at 6:15pm (couldn't have picked a better time, you idiot). Google Maps predicted that my trip would take 2 to 3 hours if I left at 4pm, so I gave myself another hour and left at 3pm. The trip still took 2 hours. After much poking, twisting, pulling and laser beaming, I came out of the orthodontist with a fresh one of these
Brushing my teeth today -- just felt like I was grinding my toothbrush across, what feels like, two bricks that are my teeth. What the hell did I sign up for? 3. Whole. Years. With metal latched on to my teeth.
MY TEETH FEEL LIKE LEAD AND I CAN'T EAT YUMMY STUFF
What we did today:
1. Toy Problem
Range Class
- Build a class to represent a range of numbers that has:
- a beginning index
- an end index (optional). If there is no end index, the range should include only the passed-in start value.
- a ‘step’ (optional)
- The step is the interval at which elements are included. For instance, a step of 1 includes every element in the range, while a step of 2 includes every other element.
- You should allow a negative value for ‘step’ to count backwards. If no step is provided and the start is more than the end, assume we’re counting backwards.
- The range should have a constructor that accepts these arguments in this order:
- begining index
- end index
- step interval
- It should also support the following utility functions:
- size(): return the number of items represented by the range
- each(callback(index)): iterate over the range, passing each value to a callback function
- includes(index): return whether or not the range includes the passed value
- You should also be aware of the following caveats:
- Should return null if we are given no ‘start’ value.
- Range should use constant space, even during the each() method, * i.e. you shouldnot use an array as backing storage.
USAGE EXAMPLES:
var myRange = new Range(0,10); // a new range representing the numbers between 0 and 10 (inclusively)
var evenNumbers = new Range(2,8,2); // A range with the even numbers 2, 4, 6, and 8.
evenNumbers.each(function(val){ console.log(val+'!'); }); //Prints '2! 4! 6! 8!'
evenNumbers.size() //4
evenNumbers.includes(2) //True
evenNumbers.include(3) //False
I feel pretty bad for leaving early on my sprint partner. On the up-side, no more orthodontics appointments for the rest of the bootcamp!
3. Townhall (I left for the orthodontist before this)
4. Tapout
No comments:
Post a Comment