-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomework 1
More file actions
147 lines (114 loc) · 2.84 KB
/
Copy pathhomework 1
File metadata and controls
147 lines (114 loc) · 2.84 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Feynman Writing Prompts - Write out explanations of the following concepts
like you are explaining it to a 12 year old. Doing this will help you quickly
discover any holes in your understanding. Ask your questions on Slack.
--Variables:
imagine the variable as an empty bucket where you can save any type of information inside it,
and change what inside it anytime during the program.
--Strings:
a type of information used to represent alphabetical characters like names, addresses, food and other things
--Functions (arguments, return):
Function is a statement tells the computer to start list of instructions when we call it inside the program,
while the arguments is the values that represent the actual value inside function. And finally return;
returns the values or the arguments after the computation inside the function and end the function.
--if statements:
Its like a police check point where its got a stop sign and stop the flow of the information
--Boolean values (true, false):
its like yes or no, 0 or 1.
function multiplyByTen(num) {
return num * 10;
}
function subtractFive(num) {
return num - 5;
}
function areSameLength(str1, str2) {
if(str1.length === str2.length) {
return true;
}
return false;
}
function areEqual(x, y) {
if(x === y){
return true;
}
return false;
}
function lessThanNinety(num) {
if(num < 90){
return true;
}
return false;
}
function greaterThanFifty(num) {
if(num > 50){
return true;
}
return false;
}
function add(x, y) {
return x + y;
}
function subtract(x, y) {
return x - y;
}
function divide(x, y) {
return x / y;
}
function multiply(x, y) {
return x * y;
}
function getRemainder(x, y) {
return x % y;
}
function isEven(num) {
if(num % 2 === 0) {
return true;
}
return false;
}
function isOdd(num) {
if(num % 2 === 1) {
return true;
}
return false;
}
function square(num) {
return math.pow(num, 2);
}
function cube(num) {
return math.pow(num, 3);
}
function raiseToPower(num, exponent) {
return math.pow(num, exponent);
}
function roundNumber(num) {
return math.round(num);
}
function roundUp(num) {
return math.ceil(num);
}
function addExclamationPoint(str) {
var exclamation = '!';
newStr = str + exclamation;
return newStr;
}
function combineNames(firstName, lastName) {
var combined = firstName + ' ' + lastName;
return combined;
}
function getGreeting(name) {
greeted = 'hello' + ' ' + name + '!';
return greeted;
}
// If you can't remember these area formulas then head over to Google or look at the test code.
function getRectangleArea(length, width) {
return length * width;
}
function getTriangleArea(base, height) {
return 0.5 * base * height;
}
function getCircleArea(radius) {
return Math.round(Math.PI * Math.pow(radius, 2));
}
function getRectangularPrismVolume(length, width, height) {
return length * width * height;
}