-
Notifications
You must be signed in to change notification settings - Fork 31
/
code-challenges.test.js
56 lines (41 loc) · 1.76 KB
/
code-challenges.test.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
// ASSESSMENT 3: Coding Practical Questions with Jest
// Please read all questions thoroughly
// Pseudo coding is REQUIRED
// If you get stuck, please leave comments to help us understand your thought process
// Use test driven development to complete the following questions
// Add appropriate dependencies: $ yarn add jest
// Reminder: The test will call your function
// Run the file with the following command: $ yarn jest
// --------------------1) Prompt: Create a function that takes in a number (greater than 2) and returns an array containing the Fibonacci sequence. The length of the array is determined by the argument of the function.
// a) Create a test with expect statements for each of the variables provided.
const fibonacciLength1 = 6
// Expected output: [1, 1, 2, 3, 5, 8]
const fibonacciLength2 = 10
// Expected output: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
// b) Create the function that makes the test pass.
// Pseudo code:
// --------------------2) For the following prompt, use ChatGPT or an equivalent AI tool to help you solve the problem. The prompt will require the use of a JavaScript method called Object.values()
// Prompt: Create a function that takes in an object and returns an array of the object's values sorted from least to greatest.
// a) Create a test with expect statements for each of the variables provided.
const studyMinutesWeek1 = {
sunday: 90,
monday: 30,
tuesday: 20,
wednesday: 15,
thursday: 30,
friday: 15,
saturday: 60
}
// Expected output: [15, 15, 20, 30, 30, 60, 90]
const studyMinutesWeek2 = {
sunday: 100,
monday: 10,
tuesday: 45,
wednesday: 60,
thursday: 20,
friday: 15,
saturday: 65
}
// Expected output: [10, 15, 20, 45, 60, 65, 100]
// b) Create the function that makes the test pass.
// Pseudo code: