You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
result="The submitted code cannot be ran by the test-runner. There is no configuration file inside the .meta (or .exercism) directory, and the fallback test file '${test_file}' does not exist. Please fix these issues and resubmit."
# TODO: interpret the tsc_result lines and pull out the source.
382
409
# We actually already have code to do this, given the cursor position
383
410
#
384
-
tsc_result=$(cat $result_file| jq -Rsa .| sed -e 's/^"//' -e 's/"$//')
385
-
tsc_result="The submitted code didn't compile. We have collected the errors encountered during compilation. At this moment the error messages are not very read-friendly, but it's a start. We are working on a more helpful output.\n-------------------------------\n$tsc_result"
tsc_result="$(cat $result_file| jq -Rsa .| sed -e 's/^"//' -e 's/"$//')"
412
+
tsc_result="The submitted code didn't compile. We have collected the errors encountered during compilation. At this moment the error messages are not very read-friendly, but it's a start. We are working on a more helpful output.\n-------------------------------\n${tsc_result}"
tstyche_result=$(echo $tstyche_error_output| jq -Rsa .| sed -e 's/^"//' -e 's/"$//')
459
+
tstyche_result=$(echo "${tstyche_error_output}"| jq -Rsa .| sed -e 's/^"//' -e 's/"$//'| sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
433
460
tstyche_result="The submitted code did compile but at least one of the type-tests failed. We have collected the failing test encountered. At this moment the error messages are not very read-friendly, but it's a start. We are working on a more helpful output.\n-------------------------------\n${tstyche_result}"
echo"❌ neither type tests, nor execution tests ran"
502
539
runner_result="The submitted code was not subjected to any type or execution tests. It did compile correctly, but something is wrong because at least one test was expected."
Lucian's girlfriend is on her way home, and he hasn't cooked their anniversary dinner!
4
+
5
+
In this exercise, you're going to write some code to help Lucian cook an exquisite lasagna from his favorite cookbook.
6
+
7
+
You have four tasks related to the time spent cooking the lasagna.
8
+
9
+
## 1. Define the expected oven time in minutes
10
+
11
+
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`.
12
+
13
+
## 2. Calculate the remaining oven time in minutes
14
+
15
+
Implement the `remainingMinutesInOven` function that takes the actual minutes the lasagna has been in the oven as a _parameter_ and _returns_ how many minutes the lasagna still has to remain in the oven, based on the **expected oven time in minutes** from the previous task.
16
+
17
+
```javascript
18
+
remainingMinutesInOven(30)
19
+
// => 10
20
+
```
21
+
22
+
## 3. Calculate the preparation time in minutes
23
+
24
+
Implement the `preparationTimeInMinutes` function that takes the number of layers you added to the lasagna as a _parameter_ and _returns_ how many minutes you spent preparing the lasagna, assuming each layer takes you 2 minutes to prepare.
25
+
26
+
```javascript
27
+
preparationTimeInMinutes(2)
28
+
// => 4
29
+
```
30
+
31
+
## 4. Calculate the total working time in minutes
32
+
33
+
Implement the `totalTimeInMinutes` function that takes _two parameters_: the `numberOfLayers` parameter is the number of layers you added to the lasagna, and the `actualMinutesInOven` parameter is the number of minutes the lasagna has been in the oven. The function should _return_ how many minutes in total you've worked on cooking the lasagna, which is the sum of the preparation time in minutes, and the time in minutes the lasagna has spent in the oven at the moment.
JavaScript is a dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.
4
+
5
+
## (Re-)Assignment
6
+
7
+
There are a few primary ways to assign values to names in JavaScript - using variables or constants. On Exercism, variables are always written in [camelCase][wiki-camel-case]; constants are written in [SCREAMING_SNAKE_CASE][wiki-snake-case]. There is no official guide to follow, and various companies and organizations have various style guides. _Feel free to write variables any way you like_. The upside from writing them the way the exercises are prepared is that they'll be highlighted differently in the web interface and most IDEs.
8
+
9
+
Variables in JavaScript can be defined using the [`const`][mdn-const], [`let`][mdn-let] or [`var`][mdn-var] keyword.
10
+
11
+
A variable can reference different values over its lifetime when using `let` or `var`. For example, `myFirstVariable` can be defined and redefined many times using the assignment operator `=`:
12
+
13
+
```javascript
14
+
let myFirstVariable =1
15
+
myFirstVariable ='Some string'
16
+
myFirstVariable =newSomeComplexClass()
17
+
```
18
+
19
+
In contrast to `let` and `var`, variables that are defined with `const` can only be assigned once. This is used to define constants in JavaScript.
20
+
21
+
```javascript
22
+
constMY_FIRST_CONSTANT=10
23
+
24
+
// Can not be re-assigned.
25
+
MY_FIRST_CONSTANT=20
26
+
// => TypeError: Assignment to constant variable.
27
+
```
28
+
29
+
> 💡 In a later Concept Exercise the difference between _constant_ assignment / binding and _constant_ value is explored and explained.
30
+
31
+
## Function Declarations
32
+
33
+
In JavaScript, units of functionality are encapsulated in _functions_, usually grouping functions together in the same file if they belong together. These functions can take parameters (arguments), and can _return_ a value using the `return` keyword. Functions are invoked using `()` syntax.
34
+
35
+
```javascript
36
+
functionadd(num1, num2) {
37
+
return num1 + num2
38
+
}
39
+
40
+
add(1, 3)
41
+
// => 4
42
+
```
43
+
44
+
> 💡 In JavaScript there are _many_ different ways to declare a function. These other ways look different than using the `function` keyword. The track tries to gradually introduce them, but if you already know about them, feel free to use any of them. In most cases, using one or the other isn't better or worse.
45
+
46
+
## Exposing to Other Files
47
+
48
+
To make a `function`, a constant, or a variable available in _other files_, they need to be [exported][mdn-export] using the `export` keyword. Another file may then [import][mdn-import] these using the `import` keyword. This is also known as the module system. A great example is how all the tests work. Each exercise has at least one file, for example `lasagna.js`, which contains the _implementation_. Additionally there is at least one other file, for example `lasagna.spec.js`, that contains the _tests_. This file _imports_ the public (i.e. exported) entities in order to test the implementation:
0 commit comments