Skip to content

Commit 27fa7f5

Browse files
committed
Completed project-1.js
1 parent 7cd3ce3 commit 27fa7f5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/project-1.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,137 +3,162 @@
33
const multiplyByTen = (num) => {
44
// return num after multiplying it by ten
55
// code here
6+
return num * 10;
67
};
78

89
const subtractFive = (num) => {
910
// return num after subtracting five
1011
// code here
12+
return num - 5;
1113
};
1214

1315
const areSameLength = (str1, str2) => {
1416
// return true if the two strings have the same length
1517
// otherwise return false
1618
// code here
19+
return (str1.length === str2.length) === true;
1720
};
1821

1922
const areEqual = (x, y) => {
2023
// return true if x and y are the same
2124
// otherwise return false
2225
// code here
26+
return (x === y) === true;
2327
};
2428

2529
const lessThanNinety = (num) => {
2630
// return true if num is less than ninety
2731
// otherwise return false
2832
// code here
33+
return (num < 90) === true;
2934
};
3035

3136
const greaterThanFifty = (num) => {
3237
// return true if num is greater than fifty
3338
// otherwise return false
3439
// code here
40+
return (num > 50) === true;
3541
};
3642

3743
const add = (x, y) => {
3844
// add x and y together and return the value
3945
// code here
46+
return x + y;
4047
};
4148

4249
const subtract = (x, y) => {
4350
// subtract y from x and return the value
4451
// code here
52+
return x - y;
4553
};
4654

4755
const divide = (x, y) => {
4856
// divide x by y and return the value
4957
// code here
58+
return x / y;
5059
};
5160

5261
const multiply = (x, y) => {
5362
// multiply x by y and return the value
5463
// code here
64+
return x * y;
5565
};
5666

5767
const getRemainder = (x, y) => {
5868
// return the remainder from dividing x by y
5969
// code here
70+
return x % y;
6071
};
6172

6273
const isEven = (num) => {
6374
// return true if num is even
6475
// otherwise return false
6576
// code here
77+
return (num % 2 === 0) === true;
6678
};
6779

6880
const isOdd = (num) => {
6981
// return true if num is odd
7082
// otherwise return false
7183
// code here
84+
return (num % 2 === 1) === true;
7285
};
7386

7487
const square = (num) => {
7588
// square num and return the new value
7689
// code here
90+
return Math.pow(num, 2);
7791
};
7892

7993
const cube = (num) => {
8094
// cube num and return the new value
8195
// code here
96+
return Math.pow(num, 3);
8297
};
8398

8499
const raiseToPower = (num, exponent) => {
85100
// raise num to whatever power is passed in as exponent
86101
// code here
102+
return Math.pow(num, exponent);
87103
};
88104

89105
const roundNumber = (num) => {
90106
// round num and return it
91107
// code here
108+
return Math.round(num);
92109
};
93110

94111
const roundUp = (num) => {
95112
// round num up and return it
96113
// code here
114+
return Math.ceil(num);
97115
};
98116

99117
const addExclamationPoint = (str) => {
100118
// add an exclamation point to the end of str and return the new string
101119
// 'hello world' -> 'hello world!'
102120
// code here
121+
return `${str}!`;
103122
};
104123

105124
const combineNames = (firstName, lastName) => {
106125
// return firstName and lastName combined as one string and separated by a space.
107126
// 'Lambda', 'School' -> 'Lambda School'
108127
// code here
128+
return `${firstName} ${lastName}`;
109129
};
110130

111131
const getGreeting = (name) => {
112132
// Take the name string and concatenate other strings onto it so it takes the following form:
113133
// 'Sam' -> 'Hello Sam!'
114134
// code here
135+
return `Hello ${name}!`;
115136
};
116137

117138
// If you can't remember these area formulas then head over to Google or look at the test code.
118139

119140
const getRectangleArea = (length, width) => {
120141
// return the area of the rectangle by using length and width
121142
// code here
143+
return length * width;
122144
};
123145

124146
const getTriangleArea = (base, height) => {
125147
// return the area of the triangle by using base and height
126148
// code here
149+
return 0.5 * base * height;
127150
};
128151

129152
const getCircleArea = (radius) => {
130153
// return the rounded area of the circle given the radius
131154
// code here
155+
return Math.round(Math.PI * Math.pow(radius, 2));
132156
};
133157

134158
const getRectangularPrismVolume = (length, width, height) => {
135159
// return the volume of the 3D rectangular prism given the length, width, and height
136160
// code here
161+
return length * width * height;
137162
};
138163

139164
// Do not modify code below this line.

0 commit comments

Comments
 (0)