-
Notifications
You must be signed in to change notification settings - Fork 33
/
code-challenges.test.js
38 lines (24 loc) · 1.34 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
// UNIT 4 ASSESSMENT: Coding Practical Questions with Jest
// Please read all questions thoroughly
// Pseudo coding is REQUIRED
// If you get stuck, 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) Create a function that takes in an object that contains up votes and down votes and returns the end tally.
// a) Create a test with expect statements for each of the variables provided.
const votes1 = { upVotes: 13, downVotes: 2 }
// Expected output: 11
const votes2 = { upVotes: 2, downVotes: 33 }
// Expected output: -31
// b) Create the function that makes the test pass.
// Pseudo code: