#Javascript: Lucian's Luscious Lasagna

1 messages · Page 1 of 1 (latest)

weak umbra
#

As I've said, it worked in my local machine. But didn't in the online IDEs and I am unable to pass this.

const PREPARATION_MINUTES_PER_LAYER = 2;
export const EXPECTED_MINUTES_IN_OVEN = 40;
export function remainingMinutesInOven(actualMinutesInOven) {
  return EXPECTED_MINUTES_IN_OVEN - actualMinutesInOven;
}
export function preparationTimeInMinutes(numberOfLayers) {
  return PREPARATION_MINUTES_PER_LAYER * numberOfLayers;
}
export function totalTimeInMinutes(numberOfLayers, actualMinutesInOven) {
  return PREPARATION_MINUTES_PER_LAYER * numberOfLayers + EXPECTED_MINUTES_IN_OVEN - actualMinutesInOven;
}
crimson fractal
#

What do you mean by "it worked in my local machine"? On your local machine, if you call totalTimeInMinutes(1,35), you get 37?

olive epoch
#

@crimson fractal Typescript, not Python (as the forum post shows)

#

@weak umbra Can you share the test output as text (not a screenshot)? Pixels can be hard to read.

#

@weak umbra
​​1. Do you understand what the test is doing?
2. Do you understand what the test is expecting and why?
3. Do you understand what your code returns and how it differs?
4. Do you understand why your code is returning what it returns?

weak umbra
#

which is the expected output

weak umbra
olive epoch
#

The test runner says your code returns 37.

#

​​1. Do you understand what test is failing? Do you understand what exactly it is calling?

weak umbra
#

while my local machine return 7.

olive epoch
#

I find that hard to believe. What are the function inputs?

weak umbra
#

This is the code on my machine.

#

It returned 7

olive epoch
#

I can't read pixels well

weak umbra
#
7

[Done] exited with code=0 in 0.073 seconds
olive epoch
#

Please use text, not images

weak umbra
#
 * The number of minutes it takes to prepare a single layer.
 */
const PREPARATION_MINUTES_PER_LAYER = 2;
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
 */
function remainingMinutesInOven(actualMinutesInOven) {
  return EXPECTED_MINUTES_IN_OVEN - actualMinutesInOven;
}
``````/**
 * Given a number of layers, determines the total preparation time.
 *
 * @param {number} numberOfLayers
 * @returns {number} the total preparation time
 */
function preparationTimeInMinutes(numberOfLayers) {
  return PREPARATION_MINUTES_PER_LAYER * numberOfLayers;
}

/**
 * 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
 */
function totalTimeInMinutes(numberOfLayers, actualMinutesInOven) {
  return (
    PREPARATION_MINUTES_PER_LAYER * numberOfLayers +
    EXPECTED_MINUTES_IN_OVEN -
    actualMinutesInOven
  );
}
console.log(totalTimeInMinutes(1, 35));
olive epoch
#

Which function is that running on your local machine and with what inputs?
Which function is the test running and with what inputs?

weak umbra
#

I can't copy the test case

#

totalTimeInMinutes(3, 20);
// => 26```
#
expect(totalTimeInMinutes(1, 5)).toBe(7);
expect(totalTimeInMinutes(4, 15)).toBe(23);
expect(totalTimeInMinutes(1, 35)).toBe(37);
TEST FAILURE
Error: expect(received).toBe(expected) // Object.is equality

Expected: 7
Received: 37```
olive epoch
#

Do you see what code the test is running?

weak umbra
#

But as I quoted up there, it should be

expect(totalTimeInMinutes(4, 15)).toBe(23);
expect(totalTimeInMinutes(1, 35)).toBe(37);```
olive epoch
#

Are all of those tests failing? Is there a single one which the output says is failing?

bleak elbow
#

sorry for butting in, but this is Lucian's Luscious Lasagna right?

bleak elbow
#

@olive epoch I don't think this is typescript, I just check the track and it doesnt have this exercise implemented since it is concepts. I think this is javascript

weak umbra
#

It seems like you've skipped every quote to me.

olive epoch
weak umbra
#

hmm, right

olive epoch
bleak elbow
#

Next time you should add the language name at the opening as well

olive epoch
#

Javascript: Lucian's Luscious Lasagna

weak umbra
olive epoch
#

So ... which test is failing? In English, which function is that test calling? What is the inputs? What does it expect?

weak umbra
#

I got it now.

olive epoch
#

Can you say, in English, what it is calling and expecting?

weak umbra
#

Instead I thought it were asking for how much time is left until it's finished.

weak umbra
#

the configured preparation time per layers were 2 minutes and expected time in oven was 40.

#

But the last constant is not needed in this case.

#

That was a bad explanation but hopefully you got it.

#

Thanks for helping me out.

olive epoch
#

You're welcome! Did you get the tests to all pass?

olive epoch
#

Woo! Congrats

#

In the future, you may want to run the tests on your local machine, too. Not just arbitrary random function calls 🙂 The track docs explain how to do that.

cosmic sirenBOT
#

If everything is resolved, we ask that people react to the top/original post with a :white_check_mark: (:white_check_mark:). This indicates to others that this issue has been resolved and locks the thread.
If all the tests pass and you want to further improve your solution, we encourage you to use the "Request a Code Review" feature on the website!

weak umbra
olive epoch
#

It might. Personally, I find it much faster as I have a real dev environment and I can run tests locally.

#

Also, in the future, you may want to consider that the people helping you actually know what they are about and answering the questions asked directly 😉

#

I've been coding for over 20 years. I've mentored thousands of solutions. I've probably helped dozens of people with this exact exercise on Discord. You were misunderstanding what the test was and refusing to answer my question about reading what test was failing.

weak umbra
#

I am sorry for that and will pay more attention next time.

olive epoch
#

No worries and thank you. Good luck with the rest of the exercise!

weak umbra
#

Thank you.

#

+close

#

.close