Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down