forked from devleague/js-functions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.js
149 lines (127 loc) · 2.89 KB
/
functions.js
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
148
149
/**
* Converts a number a string.
* @param {number} n
* @return {string} the number as a string
*/
function numberToString(num){
var str = '';
str+=num;
return str;
}
/**
* Adds one to a given number.
* @param {number} n
* @return {number}
*/
/**
* Subtracts one from a given number.
* @param {number} n
* @return {number}
*/
/**
* Adds two numbers.
* @param {number} x
* @param {number} y
* @return {number} the sum
*/
/**
* Subtracts the second number from the first.
* @param {number} x
* @param {number} y
* @return {number} the difference
*/
/**
* Multiplies two numbers.
* @param {number} x
* @param {number} y
* @return {number} the product
*/
/**
* Divides the first number by the second.
* @param {number} x
* @param {number} y
* @return {number} the quotient
*/
/**
* Multiplies a number by itself.
* @param {number} x, number to be squared
* @return {number} squared
*/
/**
* Performs a mathematical operation on two numbers.
* Also prints out the equation: (i.e.) "1 + 5 = 6" or "8 / 2 = 4".
* @param {string} operation "add", "subtract", "multiply", or "divide"
* @param {number} x
* @param {number} y
* @return {number} the result
*/
/**
* Returns true if `a` is greater than `b`.
* @param {number} a
* @param {number} b
* @return {boolean} `a` is larger than `b`
*/
/**
* Returns true if `a` is less than `b`.
* @param {number} a
* @param {number} b
* @return {boolean} `a` is smaller than `b`
*/
/**
* Returns true if `a` and `b` are equal.
* @param {number} a
* @param {number} b
* @return {boolean} the numbers are equal
*/
/**
* Returns the smallest value of two numbers.
* @param {number} x
* @param {number} y
* @return {number} the smallest number
*/
/**
* Returns the largest value of two numbers.
* @param {number} x
* @param {number} y
* @return {number} the largest number
*/
/**
* Returns true if `n` is even.
* @param {number} n
* @return {boolean} the number is even
*/
/**
* Returns true if `n` is odd.
* @param {number} n
* @return {boolean} the number is odd
*/
/**
* Returns a letter grade.
* "A": 90-100%
* "B": 80-89%
* "C": 70-79%
* "D": 60-69%
* "F": 0-59%
* @param {number} score
* @param {number} total maximum possible score
* @return {string} the score represented as a letter grade
*/
/**
* Checks if a `restaurant` object has are `views` field.
* If it does, increase it by 1. If it does not,
* set itsreviews` field to 1.
* @param {object} restaurant represents a restaurant
*/
/**
* Joins two strings with a space.
* @param {string} word1
* @param {string} word2
* @return {string} joined the words joined with a space
*/
/**
* Returns a circle object with the properties `circumference` and `area`.
* Use Math.PI for the value π.
* (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI)
* @param {number} radius
* @return {object} circle
*/