I have a difference of > 10000.
I need some advice; I’m a bit lost in the code at the moment.
Also, I don’t think my code style is perfect and it needs some corrections.
(')
/**
- Calculates the discounted rate for large projects, rounded up
- @param {number} ratePerHour
- @param {number} numDays: number of days the project spans
- @param {number} discount: for example 20% written as 0.2
- @returns {number} the rounded up discounted rate
*/
export function priceWithMonthlyDiscount(ratePerHour, numDays, discount) {
const percentigCost = 1 - discount;
const rateByDay = ratePerHour8;
const wholeMonthCount = Math.floor(numDays / 22);
const costsMonth = rateByDay22* percentigCost;
const remainingMonth = numDays % 22;
const remainigDays = Math.ceil(remainingMonth * 22);
const costs = (costsMonth * wholeMonthCount) + (remainigDays * rateByDay);
return Math.ceil(costs);
}
(')
failure report________
Code Run
expect(received).toBeCloseTo(expected, precision)
Test Failure
Expected: 8960
Received: 19712
Expected precision: 6
Expected difference: < 0.0000005
Received difference: 10752