forked from liammclennan/JavaScript-Koans
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08_about_operators.js
More file actions
51 lines (41 loc) · 1.35 KB
/
08_about_operators.js
File metadata and controls
51 lines (41 loc) · 1.35 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
describe("About Operators (topics/08_about_operators.js)", function () {
it("addition", function () {
let result = 0;
//starting i at 0, add i to result and increment i by 1 until i is expect to 5
for (let i = 0; i <= 5; i++) {
result = result + i;
}
expect(__).toBe(result, "What is the value of result?");
});
it("assignment addition", function () {
let result = 0;
for (let i = 0; i <= 5; i++) {
//the code below is just like saying result = result + i; but is more concise
result += i;
}
expect(__).toBe(result, "What is the value of result?");
});
it("subtraction", function () {
let result = 5;
for (let i = 0; i <= 2; i++) {
result = result - i;
}
expect(__).toBe(result, "What is the value of result?");
});
it("assignment subtraction", function () {
let result = 5;
for (let i = 0; i <= 2; i++) {
result -= i;
}
expect(__).toBe(result, "What is the value of result?");
});
//Assignment operators are available for multiplication and division as well
//let's do one more, the modulo operator, used for showing division remainder
it("modulus", function () {
let result = 10;
const x = 5;
//again this is exactly the same as result = result % x
result %= x;
expect(__).toBe(result, "What is the value of result?");
});
});