-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtdd.js
81 lines (65 loc) · 1.74 KB
/
tdd.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
75
76
77
78
79
80
81
// Describe: calculateTotalSum()
// Test: Assign constant values to three variables
// Code:
// Expected output:
// const A = 1.07
// const B = 0.99
// const C = 12.3
// Test: assign a random value to a variable
// Code:
// Expected output:
// const A = 1.07
// const B = 0.99
// const C = 12.3
// let randVar = Math.random();
// Test: assign a random value to a variable between 1 and 10
// Code:
// Expected output:
// const A = 1.07
// const B = 0.99
// const C = 12.3
// let randVar = ((Math.random() * 9) + 1);
// Test: sum the three original values together
// Code:
// Expected output:
// const A = 1.07
// const B = 0.99
// const C = 12.3
// let randVar = ((Math.random() * 9) + 1);
// let sum = A + B + C;
// console.log(sum);
// Test: sum the product of the three variables multiplied by three random
// numbers between 1 and 10, respectively
// Code:
// Expected output:
// const A = 1.07
// const B = 0.99
// const C = 12.3
// const array = [A, B, C];
// function calculateTotalSum(arrayToSum) {
// array.forEach(constantValue => {
// sum = constantValue * ((Math.random() * 9) + 1);
// })
// return sum;
// }
// console.log(calculateTotalSum(array));
//describe: roundFloatTo3Dec();
//Test: round these numbers to two decimal places
// Code:
// Expected output:
// function roundFloatTo3Dec(float) {
// const roundedFloat = Math.round(float * 100) / 100;
// return roundedFloat;
// }
// const A = 1.07
// const B = 0.99
// const C = 12.3
// const array = [A, B, C];
// function calculateTotalSum(arrayToSum) {
// array.forEach(constantValue => {
// sum = constantValue * ((Math.random() * 9) + 1);
// })
// sum = roundFloatTo3Dec(sum);
// return sum;
// }
// console.log(calculateTotalSum(array));