Skip to content

Commit

Permalink
commit tree 347d2d1805b51a2005550f471744a9dbaf8ba704
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianWangila committed Jul 8, 2022
1 parent 2b06071 commit ec8848c
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,67 @@
/* Your Code Here */

const createEmployeeRecord = (array) => {
return {
firstName: array[0],
familyName: array[1],
title: array[2],
payPerHour: array[3],
timeInEvents: [],
timeOutEvents: [],
}

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)
})
}

const timeCalc = (dateTime) => {
return parseInt(dateTime.match(/\d{4}$/)[0])
}

const dateCalc = (dateTime) => {
return dateTime.match(/\d{4}-\d{2}-\d{2}/)[0]
}
function createTimeInEvent(dateStamp){
const [date, hour] = dateStamp.split(" ")

const createTimeInEvent = (timeIn) => {
this.timeInEvents.push({
type: "TimeIn",
date: dateCalc(timeIn),
hour: timeCalc(timeIn)
hour: parseInt(hour, 10),
date,

})
return this
}


const createTimeOutEvent = (timeOut) => {
function createTimeOutEvent(dateStamp){
const [date, hour] = dateStamp.split(" ")

this.timeOutEvents.push({
type: "TimeOut",
date: dateCalc(timeOut),
hour: timeCalc(timeOut)
hour: parseInt(hour, 10),
date,

})
return this
}


const hoursWorkedOnDate = (dateCalc) => {
const timeIn = this.timeInEvents.find((event) => {
event.date == dateCalc
function hoursWorkedOnDate (dates) {
const timeIn = this.timeInEvents.find(event =>
event.date === dates)

})

const timeOut = this.timeOutEvents.find((event) => {
event.date == dateCalc
})
const timeOut = this.timeOutEvents.find(event =>
event.date === dates)

const timeWorked = (timeOut.hour - timeIn.hour) / 100
return timeWorked

}


const wagesEarnedOnDate = (date) => {
const wagesEarned = hoursWorkedOnDate.call(this, dateCalc)
const realWage = wagesEarned * this.payPerHour
return realWage
function wagesEarnedOnDate (date) {
const timeWorked = hoursWorkedOnDate.call(this, date)
return timeWorked * this.payPerHour
// return realWage

}

Expand All @@ -85,6 +79,8 @@ const createEmployeeRecord = (array) => {

}



/*
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

0 comments on commit ec8848c

Please sign in to comment.