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