|
3 | 3 | const multiplyByTen = (num) => { |
4 | 4 | // return num after multiplying it by ten |
5 | 5 | // code here |
| 6 | + return num * 10; |
6 | 7 | }; |
7 | 8 |
|
8 | 9 | const subtractFive = (num) => { |
9 | 10 | // return num after subtracting five |
10 | 11 | // code here |
| 12 | + return num - 5; |
11 | 13 | }; |
12 | 14 |
|
13 | 15 | const areSameLength = (str1, str2) => { |
14 | 16 | // return true if the two strings have the same length |
15 | 17 | // otherwise return false |
16 | 18 | // code here |
| 19 | + return (str1.length === str2.length) === true; |
17 | 20 | }; |
18 | 21 |
|
19 | 22 | const areEqual = (x, y) => { |
20 | 23 | // return true if x and y are the same |
21 | 24 | // otherwise return false |
22 | 25 | // code here |
| 26 | + return (x === y) === true; |
23 | 27 | }; |
24 | 28 |
|
25 | 29 | const lessThanNinety = (num) => { |
26 | 30 | // return true if num is less than ninety |
27 | 31 | // otherwise return false |
28 | 32 | // code here |
| 33 | + return (num < 90) === true; |
29 | 34 | }; |
30 | 35 |
|
31 | 36 | const greaterThanFifty = (num) => { |
32 | 37 | // return true if num is greater than fifty |
33 | 38 | // otherwise return false |
34 | 39 | // code here |
| 40 | + return (num > 50) === true; |
35 | 41 | }; |
36 | 42 |
|
37 | 43 | const add = (x, y) => { |
38 | 44 | // add x and y together and return the value |
39 | 45 | // code here |
| 46 | + return x + y; |
40 | 47 | }; |
41 | 48 |
|
42 | 49 | const subtract = (x, y) => { |
43 | 50 | // subtract y from x and return the value |
44 | 51 | // code here |
| 52 | + return x - y; |
45 | 53 | }; |
46 | 54 |
|
47 | 55 | const divide = (x, y) => { |
48 | 56 | // divide x by y and return the value |
49 | 57 | // code here |
| 58 | + return x / y; |
50 | 59 | }; |
51 | 60 |
|
52 | 61 | const multiply = (x, y) => { |
53 | 62 | // multiply x by y and return the value |
54 | 63 | // code here |
| 64 | + return x * y; |
55 | 65 | }; |
56 | 66 |
|
57 | 67 | const getRemainder = (x, y) => { |
58 | 68 | // return the remainder from dividing x by y |
59 | 69 | // code here |
| 70 | + return x % y; |
60 | 71 | }; |
61 | 72 |
|
62 | 73 | const isEven = (num) => { |
63 | 74 | // return true if num is even |
64 | 75 | // otherwise return false |
65 | 76 | // code here |
| 77 | + return (num % 2 === 0) === true; |
66 | 78 | }; |
67 | 79 |
|
68 | 80 | const isOdd = (num) => { |
69 | 81 | // return true if num is odd |
70 | 82 | // otherwise return false |
71 | 83 | // code here |
| 84 | + return (num % 2 === 1) === true; |
72 | 85 | }; |
73 | 86 |
|
74 | 87 | const square = (num) => { |
75 | 88 | // square num and return the new value |
76 | 89 | // code here |
| 90 | + return Math.pow(num, 2); |
77 | 91 | }; |
78 | 92 |
|
79 | 93 | const cube = (num) => { |
80 | 94 | // cube num and return the new value |
81 | 95 | // code here |
| 96 | + return Math.pow(num, 3); |
82 | 97 | }; |
83 | 98 |
|
84 | 99 | const raiseToPower = (num, exponent) => { |
85 | 100 | // raise num to whatever power is passed in as exponent |
86 | 101 | // code here |
| 102 | + return Math.pow(num, exponent); |
87 | 103 | }; |
88 | 104 |
|
89 | 105 | const roundNumber = (num) => { |
90 | 106 | // round num and return it |
91 | 107 | // code here |
| 108 | + return Math.round(num); |
92 | 109 | }; |
93 | 110 |
|
94 | 111 | const roundUp = (num) => { |
95 | 112 | // round num up and return it |
96 | 113 | // code here |
| 114 | + return Math.ceil(num); |
97 | 115 | }; |
98 | 116 |
|
99 | 117 | const addExclamationPoint = (str) => { |
100 | 118 | // add an exclamation point to the end of str and return the new string |
101 | 119 | // 'hello world' -> 'hello world!' |
102 | 120 | // code here |
| 121 | + return `${str}!`; |
103 | 122 | }; |
104 | 123 |
|
105 | 124 | const combineNames = (firstName, lastName) => { |
106 | 125 | // return firstName and lastName combined as one string and separated by a space. |
107 | 126 | // 'Lambda', 'School' -> 'Lambda School' |
108 | 127 | // code here |
| 128 | + return `${firstName} ${lastName}`; |
109 | 129 | }; |
110 | 130 |
|
111 | 131 | const getGreeting = (name) => { |
112 | 132 | // Take the name string and concatenate other strings onto it so it takes the following form: |
113 | 133 | // 'Sam' -> 'Hello Sam!' |
114 | 134 | // code here |
| 135 | + return `Hello ${name}!`; |
115 | 136 | }; |
116 | 137 |
|
117 | 138 | // If you can't remember these area formulas then head over to Google or look at the test code. |
118 | 139 |
|
119 | 140 | const getRectangleArea = (length, width) => { |
120 | 141 | // return the area of the rectangle by using length and width |
121 | 142 | // code here |
| 143 | + return length * width; |
122 | 144 | }; |
123 | 145 |
|
124 | 146 | const getTriangleArea = (base, height) => { |
125 | 147 | // return the area of the triangle by using base and height |
126 | 148 | // code here |
| 149 | + return 0.5 * base * height; |
127 | 150 | }; |
128 | 151 |
|
129 | 152 | const getCircleArea = (radius) => { |
130 | 153 | // return the rounded area of the circle given the radius |
131 | 154 | // code here |
| 155 | + return Math.round(Math.PI * Math.pow(radius, 2)); |
132 | 156 | }; |
133 | 157 |
|
134 | 158 | const getRectangularPrismVolume = (length, width, height) => { |
135 | 159 | // return the volume of the 3D rectangular prism given the length, width, and height |
136 | 160 | // code here |
| 161 | + return length * width * height; |
137 | 162 | }; |
138 | 163 |
|
139 | 164 | // Do not modify code below this line. |
|
0 commit comments