forked from bloominstituteoftechnology/Basic-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject-1.js
More file actions
124 lines (96 loc) · 3.36 KB
/
project-1.js
File metadata and controls
124 lines (96 loc) · 3.36 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Do not change any of the funcxtion names
const multiplyByTen = num => num * 10;
// return num after multiplying it by ten
const subtractFive = num => num - 5;
// return num after subtracting five
const areSameLength = (str1, str2) => str1.length === str2.length;
// return true if the two strings have the same length
// otherwise return false
const areEqual = (x, y) => x === y;
// return true if x and y are the same
// otherwise return false
const lessThanNinety = num => num < 90;
// return true if num is less than ninety
// otherwise return false
const greaterThanFifty = num => num > 50;
// return true if num is greater than fifty
// otherwise return false
const add = (x, y) => x + y;
// add x and y together and return the value
const subtract = (x, y) => x - y;
// subtract y from x and return the value
const divide = (x, y) => x / y;
// divide x by y and return the value
const multiply = (x, y) => x * y;
// multiply x by y and return the value
const getRemainder = (x, y) => x % y;
// return the remainder from dividing x by y
const isEven = num => num % 2 === 0;
// return true if num is even
// otherwise return false
const isOdd = num => num % 2 !== 0;
// return true if num is false
// otherwise return false
const square = num => num ** 2;
// square num and return the new value
const cube = num => num ** 3;
// cube num and return the new value
const raiseToPower = (num, exponent) => num ** exponent;
// raise num to whatever power is passed in as exponent
const roundNumber = (num) => {
// round num and return it
const rem = num % 1;
return rem >= 0.5 ? (num - rem) + 1 : num - rem;
};
const roundUp = (num) => {
// round num up and return it
const rem = num % 1;
return rem ? (num + 1) - rem : num;
};
const addExclamationPoint = str => `${str}!`;
// add an exclamation point to the end of str and return the new string
// 'hello world' -> 'hello world!'
const combineNames = (firstName, lastName) => `${firstName} ${lastName}`;
// return firstName and lastName combined as one string and separated by a space.
// 'Lambda', 'School' -> 'Lambda School'
const getGreeting = name => `Hello ${name}!`;
// Take the name string and concatenate other strings onto it so it takes the following form:
// 'Sam' -> 'Hello Sam!'
// If you can't remember these area formulas then head over to Google or look at the test code.
const getRectangleArea = (length, width) => length * width;
// return the area of the rectangle by using length and width
const getTriangleArea = (base, height) => (height * base) / 2;
// return the area of the triangle by using base and height
const getCircleArea = radius => Math.round((radius ** 2) * Math.PI);
// return the rounded area of the circle given the radius
const getRectangularPrismVolume = (length, width, height) => length * width * height;
// return the volume of the 3D rectangular prism given the length, width, and height
// Do not modify code below this line.
// --------------------------------
module.exports = {
multiplyByTen,
subtractFive,
areSameLength,
areEqual,
lessThanNinety,
greaterThanFifty,
add,
subtract,
divide,
multiply,
getRemainder,
isEven,
isOdd,
square,
cube,
raiseToPower,
roundNumber,
roundUp,
addExclamationPoint,
combineNames,
getGreeting,
getRectangleArea,
getTriangleArea,
getCircleArea,
getRectangularPrismVolume
};