Skip to content

Commit

Permalink
Merge pull request learn-co-curriculum#1 from learn-co-curriculum/liz…
Browse files Browse the repository at this point in the history
…bur10_patch_1

Lizbur10 patch 1
  • Loading branch information
lizbur10 committed Jul 2, 2021
2 parents 5d61e25 + 4c73968 commit 5262fc4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
40 changes: 14 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Learning Goals

* Explicitly override context with `call` and `apply`
* Explicitly lock context for a function with bind
* Update our time-card and payroll application to use the employee record as
context rather than passing it as an argument.

## Introduction

Expand Down Expand Up @@ -34,20 +34,18 @@ understand how to "grow" an application in "record-oriented" fashion in
JavaScript, as well as pass the lab. Make sure you're learning about this app
design while you pass the solutions.

As before, if you find yourself having extra time, use the guidance in the
previous lab to make your application more robust.
Code your solution in `index.js`. To get everything passing, you will need to
exercise the collection-processing strengths you developed earlier in this
Phase.

Take advantage of your collection-processing strengths that you trained up over
the last few lessons.

Put your code in `index.js`.
As before, if you have extra time, use the guidance in the previous lab to make
your application more robust.

While you will want to be guided by the tests, you will implement the following
functions. To make the tests easier to read, we've provided the _signatures_ of
the functions.

A function _signature_ is the function name, the arguments it expects, and what
the function returns.
the functions. (A function _signature_ is the function name, the arguments it
expects, and what the function returns.) Be sure to refer back to this
information as you work through the tests.

### `createEmployeeRecord`

Expand Down Expand Up @@ -89,7 +87,6 @@ the function returns.
* `hour`: Derived from the argument
* `date`: Derived from the argument


### `createTimeOutEvent`

* **Argument(s)**
Expand Down Expand Up @@ -158,20 +155,11 @@ the function returns.

You'll notice that in this lab we give you the implementation of `allWagesFor`.
As part of writing this challenge, we ran right smack into one of the most
famous bugs in JavaScript land: "the lost context bug." Because we've not
taught you to deal with it, we've "given" you this function. We think you can
solve the other tests with this little piece having been given to you.

If you find yourself having extra time, try researching this topic on your own.
We'll tell you all about it in our next lesson, though.

## Conclusion
famous bugs in JavaScript land: "the lost context bug." Because we haven't
taught you to deal with it yet, we've "given" you this function.

This is one of the hardest topics in JavaScript. But you have hands-on
experience with the why and motivations of it! You're so much better off than
most JavaScript hackers who _never_ quite get the hang of it. It's been a lot
of growth, but this hard-won knowledge is going to help you do staggeringly
cool things
If you have extra time, try researching this topic on your own. We'll tell you
all about it in our next lesson, though.

## Resources

Expand Down
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
for you to use if you need it!
*/

let allWagesFor = function () {
let eligibleDates = this.timeInEvents.map(function (e) {
const allWagesFor = function () {
const eligibleDates = this.timeInEvents.map(function (e) {
return e.date
})

let payable = eligibleDates.reduce(function (memo, d) {
const payable = eligibleDates.reduce(function (memo, d) {
return memo + wagesEarnedOnDate.call(this, d)
}.bind(this), 0) // <== Hm, why did we need to add bind() there? We'll discuss soon!

return payable
}
}

0 comments on commit 5262fc4

Please sign in to comment.