-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchallenges.test.js
More file actions
52 lines (42 loc) · 1022 Bytes
/
challenges.test.js
File metadata and controls
52 lines (42 loc) · 1022 Bytes
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
const {
stringRange,
evenString,
stringExcept,
sumUp,
power,
countDigits,
sumOfDigits,
maxMinDiff,
matrixSum,
fibonacciSum
} = require('./challenges')
test('String Range', () => {
expect(stringRange(-3, 5)).toBe('-3 -2 -1 0 1 2 3 4 5')
})
test('Even String', () => {
expect(evenString([-4, 8, 7, 0, 11, -100])).toBe('-4 8 0 -100')
})
test('String Except', () => {
expect(stringExcept([1, 3, 2, 3, 3, 3, 4, 3], 3)).toBe('1 2 4')
})
test('Sum Up', () => {
expect(sumUp(100)).toBe(100 * 101 / 2)
})
test('Power', () => {
expect(power(3, 7)).toBe(3**7)
})
test('Count Digits', () => {
expect(countDigits(918273645)).toBe(9)
})
test('Sum of Digits', () => {
expect(sumOfDigits(918273645000)).toBe(9 * 10 / 2)
}),
test('Max Min Difference', () => {
expect(maxMinDiff([-4, -6, 0, 5, 1])).toBe(11)
})
test('Matrix Sum', () => {
expect(matrixSum([[3, 2], [1, 8], [11, -2]])).toBe(5 + 9 + 9)
})
test('Fibonacci Sum', () => {
expect(fibonacciSum(100)).toBe(927372692193078999176)
})