diff --git a/index.js b/index.js index e303d299..387d33af 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,86 @@ /* Your Code Here */ +const createEmployeeRecord = (array) => { + return { + firstName: array[0], + familyName: array[1], + title: array[2], + payPerHour: array[3], + timeInEvents: [], + timeOutEvents: [], + } + +} + + const createEmployeeRecords = (employeeRecords) => { + return employeeRecords.map(arrayEmp => { + return createEmployeeRecord(arrayEmp) + }) + } + + + function createTimeInEvent(dateStamp){ + const [date, hour] = dateStamp.split(" ") + + this.timeInEvents.push({ + type: "TimeIn", + hour: parseInt(hour, 10), + date, + + }) + return this + } + + + function createTimeOutEvent(dateStamp){ + const [date, hour] = dateStamp.split(" ") + + this.timeOutEvents.push({ + type: "TimeOut", + hour: parseInt(hour, 10), + date, + + }) + return this + } + + + function hoursWorkedOnDate (dates) { + const timeIn = this.timeInEvents.find(event => + event.date === dates) + + const timeOut = this.timeOutEvents.find(event => + event.date === dates) + + const timeWorked = (timeOut.hour - timeIn.hour) / 100 + return timeWorked + + } + + + function wagesEarnedOnDate (date) { + const timeWorked = hoursWorkedOnDate.call(this, date) + return timeWorked * this.payPerHour + // return realWage + + } + + + const findEmployeeByFirstName = (employees, firstName) => { + return employees.find(employee => employee.firstName === firstName) + } + + + + const calculatePayroll = (employeeRecord) => { + return employeeRecord.reduce((total, employee) => { + return total + allWagesFor.call(employee) + }, 0) + + } + + + /* We're giving you this function. Take a look at it, you might see some usage that's new and different. That's because we're avoiding a well-known, but diff --git a/package-lock.json b/package-lock.json index 13ee0eee..b67156a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "chai": "4.1.2", "file-system": "2.2.2", "jsdom": "9.2.1", - "mocha": "5.2.0", + "mocha": "^5.2.0", "mocha-jsdom": "~1.1.0", "mocha-multi": "1.0.1" } @@ -3177,7 +3177,7 @@ "dependencies": { "combined-stream": { "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "dev": true, "requires": { @@ -3442,9 +3442,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, "lodash.once": { diff --git a/package.json b/package.json index dc887287..2f39722e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "chai": "4.1.2", "file-system": "2.2.2", "jsdom": "9.2.1", - "mocha": "5.2.0", + "mocha": "^5.2.0", "mocha-jsdom": "~1.1.0", "mocha-multi": "1.0.1" },