Open sak55 opened 9 years ago
try out our new Array
and Object
literals on those mean ole String Calculator and Check Writing katas.
Before Take a Picture of your logic for practice.
You'll need to learn some more Array
methods before we prep the floor for some API Gymnastics.
Using a diagramming tool of your choice -- Google Drawings, Gliphy, OmniGraffle, photos of pen and paper -- render a clean drawing of the logic in the toEnglish
function from Check Writing.
Save a copy of the resultant image as docs/toEnglish.png
and commit it into your branch.
Think you've mastered the String Calculator and Check Writing katas? Not by a long-shot...! Refactor your "production" (i.e. not-"test") code to use Array
and literals as Lists Object
and Dictionaries per the examples below.
Highly recommended BEFORE API Gymnastics, document the non-experimental Array
Iteration Methods and attempt to re-implement at least 3 using Array.prototype.forEach
. BEAST MODE: Also include find
and findIndex
. See Requirements below for an example of every()
.
Use the curl
command to get some crazy event data from the Github API and stick it in a file called apis/github/users/USERNAME/events.json
where USERNAME
is your Github profile name, e.g. apis/github/users/al-the-x/events.json
for moi: al-the-x
. Yes, you'll have to create some empty directories along the way... Remember how to do it in one step? Hint: Use the funnel, Luke! Following the Requirements below, use your iterator methods to pull some numbers from the data.
toEnglish()
from scripts/check-writing.js
in docs/toEnglish.png
docs/JS.md
for non-experimental Iteration Methodsscripts/
called gymnastics.js
with a function called answers
that meets Array
. . .
Array.prototype.every
callback
: Function
to test each element againstitem
: element to processindex
: index of processed elementall
: array instanceBoolean
thisArg
: Object
to which to bind callback
Boolean
whether callback
returns true
for every elementfunction every(anArray, callback){
var hasFailed = false; // it hasn't has it?
// iterate...
anArray.foreach(function(item, index, all){
if ( hasFailed ) return; // one failure ruins everything...
hasFailed = !callback(item, index, all); // why invert here?
});
return !hasFailed; // Another inverse?
// What if `anArray` is empty?
}
Next, use the methods of Array
that you've documented to uncover some statistics about your progress. You can create as many functions as you like to help you derive the answers, but place the final invocations (not just the values) into a function called answers
that returns the following:
Looking for those :+1: on that PR
Tasks
13 -- Lists + Dicts
with tasks and estimates!master
, and open a new branch:feature/13--lists+dicts
apis/github/users/USERNAME/events.json
whereUSERNAME
is... you get it.curl
or Postman to fetch your public events from the Github APIif
andreturn
(noelse
)fromEnglish()
fromEnglish()
to use at least one lookup!Array
lookups instead ofif
forEach
... a lot.every()
andsome()
crowd again.filter()
anyway?map()
over here?reduce()
this assignment...reduceRight()
...?PushEvent
entries...answers
now!