-
Notifications
You must be signed in to change notification settings - Fork 2
/
lucians-lucious-lasagna.js
74 lines (68 loc) · 2.83 KB
/
lucians-lucious-lasagna.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// @ts-check
//
// ☝🏽 The line above enables type checking for this file. Various IDEs interpret
// the @ts-check directive. It will give you helpful autocompletion on the web
// and supported IDEs when implementing this exercise. You don't need to
// understand types, JSDoc, or TypeScript in order to complete this JavaScript
// exercise, and can completely ignore this comment block and directive.
// 👋🏽 Hi there!
//
// On the JavaScript track we provide you with stubs. These stubs provide a
// starting point to solving the exercise.
//
// In general, each variable/constant and each declared function will have a
// JSDoc comment block above it, explaining what the variable/constant holds or
// the function is supposed to accomplish.
//
// 💡 Often, the JSDoc comment blocks have annotations, such as @param and
// @returns which are usually highlighted with a different color if the IDE
// you're in recognizes them. It's these annotations that are used when
// referring to the constant, variable, or function from somewhere else that
// IDEs display.
//
// You don't need to write these yourself; it is not expected in idiomatic
// JavaScript, but some companies and style-guides do enforce them.
//
// 💡 You're allowed to completely clear a stub before you get started. Often
// we recommend using the stub, because they are already set-up correctly to
// work with the tests, which you can find in ./lasagna.spec.js
//
// Good luck preparing some lasagna!
/**
* The number of minutes it takes to prepare a single layer.
*/
const PREPARATION_MINUTES_PER_LAYER = 2;
/**
* Define the EXPECTED_MINUTES_IN_OVEN constant that represents how many minutes the lasagna should be in the oven. It must be * exported. According to the cooking book, the expected oven time in minutes is 40.
*/
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) {
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
*/
export function preparationTimeInMinutes(numberOfLayers) {
return numberOfLayers * PREPARATION_MINUTES_PER_LAYER;
}
/**
* 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 actualMinutesInOven + preparationTimeInMinutes(numberOfLayers);
}