|
| 1 | +#Lodash Workout |
| 2 | + |
| 3 | +##Some Tutorials |
| 4 | +- [lodash Docs](https://lodash.com/docs) |
| 5 | +- [Intorduction to lodash (video)](https://egghead.io/lessons/core-javascript-introduction-to-lodash) |
| 6 | +- [Applicative Programming In JavaScript With lodash.js](http://tech.pro/tutorial/1611/functional-javascript) |
| 7 | +- [More tutorials here](http://bit.ly/1xSVC8R) |
| 8 | + |
| 9 | +##The Excercise |
| 10 | + |
| 11 | +Given this **person** schema: |
| 12 | +```javascript |
| 13 | + { |
| 14 | + firstName: string, |
| 15 | + lastName: string, |
| 16 | + age: number, |
| 17 | + skills: ['run', 'jump', 'swim', 'dance'], |
| 18 | + gender: string (male / female), |
| 19 | + married: boolean |
| 20 | +} |
| 21 | +``` |
| 22 | +```javascript |
| 23 | +adult schema extends person with: |
| 24 | + children: { // an object with key-value pairs, as firstName: person |
| 25 | + 'childName': {person}, |
| 26 | + 'childName': {person}, |
| 27 | + etc... |
| 28 | + } |
| 29 | +``` |
| 30 | + |
| 31 | +Given an array of adults perform the following tasks using lodash. Note that each task is a separate problems: |
| 32 | + |
| 33 | +filter by age > 30 and has skills 'run' and 'swim' |
| 34 | +filter by children who can swim or dance, and sort by gender and age |
| 35 | +get an array of population, which contains all the people (adults and children) in the array |
| 36 | +filter by people who have daughters and are not married |
| 37 | +filter by married people who can jump |
| 38 | +filter by people who have last name that starts with 'j' or later in the alphabet, and have married children |
| 39 | +change the collection so that the name of each person is |
| 40 | +name: {first: 'string', last: 'string'} |
| 41 | +instead of firstName and lastName |
| 42 | +get an array of all children |
| 43 | +get an array of just the ages: |
| 44 | + |
| 45 | +Let's say you want to do something when a certain event occurs. However, the event is fired very often when it happens. For example, when dragging something or scrolling, you want to perform some complex action, but you don't want it to happen so many times since it will slow down the UI. |
| 46 | + |
| 47 | + |
| 48 | +Create a function 'doSomething' which will only execute at most 1/x times. |
| 49 | +Create a function which will only execute 1/x seconds. |
| 50 | +Given a function, ‘get(url, data, successCallback)’ , create a function that will perform the get, but will always use a given url 'baseUrl' and specified data 'someData'. |
| 51 | + |
| 52 | + |
| 53 | + |
0 commit comments