Skip to content

Commit 2d558ab

Browse files
Alexander StewartAlexander Stewart
authored andcommitted
pj1comp
1 parent 6120bd0 commit 2d558ab

File tree

1 file changed

+63
-31
lines changed

1 file changed

+63
-31
lines changed

src/project-1.js

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,172 @@
11
// Do not change any of the funcxtion names
22

3-
const multiplyByTen = (num) => {
3+
const multiplyByTen = num => num * 10;
44
// return num after multiplying it by ten
55
// code here
6-
};
76

8-
const subtractFive = (num) => {
7+
const subtractFive = num => num - 5;
98
// return num after subtracting five
109
// code here
11-
};
1210

1311
const areSameLength = (str1, str2) => {
12+
if (str1.length === str2.length) {
13+
return true;
14+
}
15+
return false;
16+
};
1417
// return true if the two strings have the same length
1518
// otherwise return false
1619
// code here
17-
};
20+
1821

1922
const areEqual = (x, y) => {
23+
if (x === y) {
24+
return true;
25+
}
26+
return false;
27+
};
28+
2029
// return true if x and y are the same
2130
// otherwise return false
2231
// code here
23-
};
32+
2433

2534
const lessThanNinety = (num) => {
35+
if (num < 90) {
36+
return true;
37+
}
38+
return false;
39+
};
2640
// return true if num is less than ninety
2741
// otherwise return false
2842
// code here
29-
};
43+
3044

3145
const greaterThanFifty = (num) => {
46+
if (num > 50) {
47+
return true;
48+
}
49+
return false;
50+
};
3251
// return true if num is greater than fifty
3352
// otherwise return false
3453
// code here
35-
};
3654

37-
const add = (x, y) => {
55+
56+
const add = (x, y) => x + y;
3857
// add x and y together and return the value
3958
// code here
40-
};
4159

42-
const subtract = (x, y) => {
60+
61+
const subtract = (x, y) => x - y;
4362
// subtract y from x and return the value
4463
// code here
45-
};
4664

47-
const divide = (x, y) => {
65+
66+
const divide = (x, y) => (x / y);
4867
// divide x by y and return the value
4968
// code here
50-
};
5169

52-
const multiply = (x, y) => {
70+
const multiply = (x, y) => x * y;
5371
// multiply x by y and return the value
5472
// code here
55-
};
5673

57-
const getRemainder = (x, y) => {
74+
75+
const getRemainder = (x, y) => x % y;
5876
// return the remainder from dividing x by y
5977
// code here
60-
};
6178

6279
const isEven = (num) => {
80+
if (num % 2 === 0) {
81+
return true;
82+
}
83+
return false;
84+
};
6385
// return true if num is even
6486
// otherwise return false
6587
// code here
66-
};
6788

6889
const isOdd = (num) => {
90+
if (num % 2 !== 0) {
91+
return true;
92+
}
93+
return false;
6994
// return true if num is false
7095
// otherwise return false
7196
// code here
7297
};
7398

74-
const square = (num) => {
99+
const square = num => num * num;
75100
// square num and return the new value
76101
// code here
77-
};
78102

79-
const cube = (num) => {
103+
104+
const cube = num => num * num * num;
80105
// cube num and return the new value
81106
// code here
82-
};
107+
83108

84109
const raiseToPower = (num, exponent) => {
110+
return num ** exponent;
111+
};
85112
// raise num to whatever power is passed in as exponent
86113
// code here
87-
};
88114

89115
const roundNumber = (num) => {
116+
return Math.round(num);
90117
// round num and return it
91118
// code here
92119
};
93120

94121
const roundUp = (num) => {
122+
return Math.ceil(num);
95123
// round num up and return it
96124
// code here
97125
};
98126

99127
const addExclamationPoint = (str) => {
128+
const newStr = `${str}!`;
129+
return newStr;
100130
// add an exclamation point to the end of str and return the new string
101131
// 'hello world' -> 'hello world!'
102132
// code here
103133
};
104134

105135
const combineNames = (firstName, lastName) => {
136+
const newStr = `${firstName} ${lastName}`;
137+
return newStr;
106138
// return firstName and lastName combined as one string and separated by a space.
107139
// 'Lambda', 'School' -> 'Lambda School'
108140
// code here
109141
};
110142

111143
const getGreeting = (name) => {
144+
return `Hello ${name}!`;
112145
// Take the name string and concatenate other strings onto it so it takes the following form:
113146
// 'Sam' -> 'Hello Sam!'
114147
// code here
115148
};
116149

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

119-
const getRectangleArea = (length, width) => {
152+
const getRectangleArea = (length, width) => length * width;
120153
// return the area of the rectangle by using length and width
121154
// code here
122-
};
123155

124-
const getTriangleArea = (base, height) => {
156+
const getTriangleArea = (base, height) => (base * height) / 2;
125157
// return the area of the triangle by using base and height
126158
// code here
127-
};
159+
128160

129161
const getCircleArea = (radius) => {
162+
return Math.round(Math.PI * radius * radius);
163+
};
130164
// return the rounded area of the circle given the radius
131165
// code here
132-
};
133166

134-
const getRectangularPrismVolume = (length, width, height) => {
167+
const getRectangularPrismVolume = (length, width, height) => length * width * height;
135168
// return the volume of the 3D rectangular prism given the length, width, and height
136169
// code here
137-
};
138170

139171
// Do not modify code below this line.
140172
// --------------------------------

0 commit comments

Comments
 (0)