Lasagna probably error test

The test of this exercise, throws this error message:
CALCULATE THE TOTAL WORKING TIME IN MINUTES
Test 5 totalTimeInMinutes > Calculates the total cooking time

Code Run
expect(totalTimeInMinutes(1, 5)).toBe(7);
expect(totalTimeInMinutes(4, 15)).toBe(23);
expect(totalTimeInMinutes(1, 30)).toBe(32);

Test Failure
Error: expect(received).toBe(expected) // Object.is equality

Expected: 7
Received: 37

I think that this test is wrong, because:
expect(totalTimeInMinutes(1, 5)).toBe(7); // It can’t be 7,
because:
- preparationTimeInMinutes(1) → returns 2
- cookingTimeInMinutes(1) → returns 35
- total cooking time is 2 + 35 = 37

expect(totalTimeInMinutes(4, 15)).toBe(23); //It can’t be 23,
because:
- preparationTimeInMinutes(4) → returns 8
- cookingTimeInMinutes(15) → returns 25
- total cooking time is 8 + 25 = 33

expect(totalTimeInMinutes(1, 30)).toBe(32); // It can’t be,
because:
- preparationTimeInMinutes(1) → returns 2
- cookingTimeInMinutes(30) → returns 10
- total cooking time is 8 + 25 = 12
Thanks.

Hi!
I don’t think that the test is wrong. I would suggest checking the formula again since the first value indicates the number of layers, and the second value indicates the actual minutes in the oven. Thus, the operation should be the total prep time of X number of layers plus the actual minutes in oven value as it is. :slight_smile:

Hi!
My code is the next, and I would be grateful if you could take a look at it.

/**

  • The number of minutes it takes to prepare a single layer.
    */
    const PREPARATION_MINUTES_PER_LAYER = 2;

export const EXPECTED_MINUTES_IN_OVEN = 40;

/**

  • Determines the number of minutes the lasagna still needs to remain in the
  • oven to be properly prepared.
  • @param {number} actualMinutesInOven
  • @returns {number} the number of minutes remaining
    */
    export function remainingMinutesInOven(actualMinutesInOven) {
    let minutes = EXPECTED_MINUTES_IN_OVEN - actualMinutesInOven;
    return parseInt(minutes);
    }

/**

  • Given a number of layers, determines the total preparation time.
  • @param {number} numberOfLayers
  • @returns {number} the total preparation time
    */
    export function preparationTimeInMinutes(numberOfLayers) {
    let preparation = numberOfLayers * PREPARATION_MINUTES_PER_LAYER;
    return parseInt(preparation);
    }

/**

  • Calculates the total working time. That is, the time to prepare all the layers
  • of lasagna, and the time already spent in the oven.
  • @param {number} numberOfLayers
  • @param {number} actualMinutesInOven
  • @returns {number} the total working time
    */
    export function totalTimeInMinutes(numberOfLayers, actualMinutesInOven) {
    return (preparationTimeInMinutes(numberOfLayers)) + (remainingMinutesInOven(actualMinutesInOven));
    }

The total time that passed should not consider remainingMinutesInOven. The remaining time is time in the future; it is not time that already passed.

1 Like

Hi!
Thank you so much!