Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

Commit c60c9f2

Browse files
committed
Improving commenting and format files
1 parent ce8e328 commit c60c9f2

File tree

10 files changed

+68
-79
lines changed

10 files changed

+68
-79
lines changed

exercises/D-predicates/exercise.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
*/
77

88
// Finish the predicate function to test if the passed number is negative (less than zero)
9-
function isNegative(number) {
10-
11-
}
9+
function isNegative(number) {}
1210

1311
// Finish the predicate function to test if the passed number is between 0 and 10
14-
function isBetweenZeroAnd10(number) {
15-
16-
}
12+
function isBetweenZeroAnd10(number) {}
1713

1814
/*
1915
DO NOT EDIT BELOW THIS LINE
@@ -32,4 +28,3 @@ console.log("Is the number between 0 and 10? " + numberBetweenZeroAnd10);
3228
Is the number negative? false
3329
Is the number between 0 and 10? true
3430
*/
35-

exercises/F-logical-operators/exercise.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ var cssOrHtmlAbove5;
2727
console.log("Is Html knowledge above 5?", htmlLevelAbove5);
2828
console.log("Is CSS knowledge above 5?", cssLevelAbove5);
2929
console.log("Is Html And CSS knowledge above 5?", cssAndHtmlAbove5);
30-
console.log(
31-
"Is either Html or CSS knowledge above 5?",
32-
cssOrHtmlAbove5
33-
);
30+
console.log("Is either Html or CSS knowledge above 5?", cssOrHtmlAbove5);
3431

3532
/*
3633
EXPECTED RESULT

exercises/G-conditionals-2/exercise-1.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
- if number is more or equal to zero, return the word "positive"
77
*/
88

9-
function negativeOrPositive(number) {
10-
11-
}
9+
function negativeOrPositive(number) {}
1210

1311
/*
1412
DO NOT EDIT BELOW THIS LINE

exercises/G-conditionals-2/exercise-2.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
88
*/
99

10-
function studentPassed(grade) {
11-
12-
}
10+
function studentPassed(grade) {}
1311

1412
/*
1513
DO NOT EDIT BELOW THIS LINE
@@ -18,9 +16,9 @@ var grade1 = 49;
1816
var grade2 = 50;
1917
var grade3 = 100;
2018

21-
console.log("'" + grade1 + "': " + studentPassed(grade1))
22-
console.log("'" + grade2 + "': " + studentPassed(grade2))
23-
console.log("'" + grade3 + "': " + studentPassed(grade3))
19+
console.log("'" + grade1 + "': " + studentPassed(grade1));
20+
console.log("'" + grade2 + "': " + studentPassed(grade2));
21+
console.log("'" + grade3 + "': " + studentPassed(grade3));
2422

2523
/*
2624
EXPECTED RESULT

exercises/G-conditionals-2/exercise-3.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
- Otherwise the grade is "F"
99
*/
1010

11-
function calculateGrade(mark) {
12-
13-
}
11+
function calculateGrade(mark) {}
1412

1513
/*
1614
DO NOT EDIT BELOW THIS LINE
@@ -25,7 +23,7 @@ console.log("'" + grade2 + "': " + calculateGrade(grade2));
2523
console.log("'" + grade3 + "': " + calculateGrade(grade3));
2624
console.log("'" + grade4 + "': " + calculateGrade(grade4));
2725

28-
/*
26+
/*
2927
EXPECTED RESULT
3028
---------------
3129
'49': F

exercises/G-conditionals-2/exercise-4.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
Hint: Google how to check if a string contains a word
99
*/
1010

11-
function containsCode(sentence) {
12-
13-
}
11+
function containsCode(sentence) {}
1412

1513
/*
1614
DO NOT EDIT BELOW THIS LINE
@@ -19,11 +17,11 @@ var sentence1 = "code your future";
1917
var sentence2 = "draw your future";
2018
var sentence3 = "design your future";
2119

22-
console.log("'" + sentence1 + "': " + containsCode(sentence1))
23-
console.log("'" + sentence2 + "': " + containsCode(sentence2))
24-
console.log("'" + sentence3 + "': " + containsCode(sentence3))
20+
console.log("'" + sentence1 + "': " + containsCode(sentence1));
21+
console.log("'" + sentence2 + "': " + containsCode(sentence2));
22+
console.log("'" + sentence3 + "': " + containsCode(sentence3));
2523

26-
/*
24+
/*
2725
EXPECTED RESULT
2826
---------------
2927
'code your future': true

extra/1-radio-stations.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*/
2727
// `getStations` goes here
2828

29-
3029
/* ======= TESTS - DO NOT MODIFY ======= */
3130

3231
function getAvailableStations() {
@@ -36,10 +35,10 @@ function getAvailableStations() {
3635
const stationCount = 4;
3736
getAvailableStations.stations = new Array(stationCount)
3837
.fill(undefined)
39-
.map(function() {
38+
.map(function () {
4039
return Math.floor(Math.random() * (108 - 87 + 1) + 87);
4140
})
42-
.sort(function(frequencyA, frequencyB) {
41+
.sort(function (frequencyA, frequencyB) {
4342
return frequencyA - frequencyB;
4443
});
4544
}
@@ -64,7 +63,7 @@ function test(testName, fn) {
6463
}
6564
}
6665

67-
test("getAllFrequencies() returns all frequencies between 87 and 108", function() {
66+
test("getAllFrequencies() returns all frequencies between 87 and 108", function () {
6867
const frequencies = getAllFrequencies();
6968
assert.deepStrictEqual(frequencies, [
7069
87,
@@ -88,7 +87,7 @@ test("getAllFrequencies() returns all frequencies between 87 and 108", function(
8887
105,
8988
106,
9089
107,
91-
108
90+
108,
9291
]);
9392
});
9493

mandatory/1-fix-functions.js

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
// The below functions are syntactically correct but not outputting the right results.
2-
// Look at the tests and see how you can fix them.
1+
/* Fix Functions
2+
3+
Aim: to understand the change code inside functions
4+
5+
See the below functions. They are syntactically correct but are not outputting the right results.
6+
7+
Run the tests and see how you can fix them.
8+
9+
NOTE:Only make edits inside the function
10+
11+
*/
312

413
function mood() {
514
let isHappy = true;
@@ -42,7 +51,7 @@ function get3rdIndex(arr) {
4251

4352
/* ======= TESTS - DO NOT MODIFY ===== */
4453

45-
const util = require('util');
54+
const util = require("util");
4655

4756
function test(test_name, actual, expected) {
4857
let status;
@@ -57,7 +66,9 @@ function test(test_name, actual, expected) {
5766
if (isEqual) {
5867
status = "PASSED";
5968
} else {
60-
status = `FAILED: expected: ${util.inspect(expected)} but your function returned: ${util.inspect(actual)}`;
69+
status = `FAILED: expected: ${util.inspect(
70+
expected
71+
)} but your function returned: ${util.inspect(actual)}`;
6172
}
6273

6374
console.log(`${test_name}: ${status}`);
@@ -79,25 +90,32 @@ test("mood function works for true", mood(true), "I am happy");
7990
test("mood function works for false", mood(false), "I am not happy");
8091
test(
8192
"greaterThanTen function works for 11",
82-
greaterThan10(11), "num is greater than 10"
93+
greaterThan10(11),
94+
"num is greater than 10"
8395
);
8496
test(
8597
"greaterThanTen function works for 10",
86-
greaterThan10(10), "num is not big enough"
98+
greaterThan10(10),
99+
"num is not big enough"
87100
);
88101
test(
89102
"greaterThanTen function works for 9",
90-
greaterThan10(9), "num is not big enough"
91-
);
92-
test(
93-
"sortArray function works",
94-
sortArray(["a", "n", "c", "e", "z", "f"]), ["a", "c", "e", "f", "n", "z"]
103+
greaterThan10(9),
104+
"num is not big enough"
95105
);
106+
test("sortArray function works", sortArray(["a", "n", "c", "e", "z", "f"]), [
107+
"a",
108+
"c",
109+
"e",
110+
"f",
111+
"n",
112+
"z",
113+
]);
96114

97115
let numbers = [1, 2, 3, 4, 5, 6, 7, 8];
98116
test("first5 function works", first5(numbers), [1, 2, 3, 4, 5]);
99117
if (!arraysEqual(numbers, [1, 2, 3, 4, 5, 6, 7, 8])) {
100-
console.log("PROBLEM: first5 changed its input array - it shouldn't!")
118+
console.log("PROBLEM: first5 changed its input array - it shouldn't!");
101119
}
102120

103121
test(

mandatory/2-function-creation.js

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ Write a function that:
3434
- numbers greater 100 must be replaced with 100
3535
*/
3636

37-
function formatPercentage(arr) {
38-
39-
}
37+
function formatPercentage(arr) {}
4038

4139
/* ======= TESTS - DO NOT MODIFY ===== */
4240

43-
const util = require('util');
41+
const util = require("util");
4442

4543
function test(test_name, actual, expected) {
4644
let status;
@@ -55,7 +53,9 @@ function test(test_name, actual, expected) {
5553
if (isEqual) {
5654
status = "PASSED";
5755
} else {
58-
status = `FAILED: expected: ${util.inspect(expected)} but your function returned: ${util.inspect(actual)}`;
56+
status = `FAILED: expected: ${util.inspect(
57+
expected
58+
)} but your function returned: ${util.inspect(actual)}`;
5959
}
6060

6161
console.log(`${test_name}: ${status}`);
@@ -75,12 +75,8 @@ function arraysEqual(a, b) {
7575

7676
test(
7777
"tidyUpString function works - case 1",
78-
tidyUpString(["/Daniel ", "irina ", " Gordon", "ashleigh "]), [
79-
"daniel",
80-
"irina",
81-
"gordon",
82-
"ashleigh"
83-
]
78+
tidyUpString(["/Daniel ", "irina ", " Gordon", "ashleigh "]),
79+
["daniel", "irina", "gordon", "ashleigh"]
8480
);
8581
test(
8682
"tidyUpString function works - case 2",
@@ -94,28 +90,20 @@ test("validate function works - case 3", validate(17), false);
9490
test("validate function works - case 4", validate("Ten"), false);
9591
test("validate function works - case 5", validate(108), false);
9692

97-
test(
98-
"remove function works - case 1",
99-
remove([10, 293, 292, 176, 29], 3), [10, 293, 292, 29]
100-
);
93+
test("remove function works - case 1", remove([10, 293, 292, 176, 29], 3), [
94+
10,
95+
293,
96+
292,
97+
29,
98+
]);
10199
test(
102100
"remove function works - case 2",
103-
remove(["a", "b", "c", "d", "e", "f", "g"], 6), [
104-
"a",
105-
"b",
106-
"c",
107-
"d",
108-
"e",
109-
"f"
110-
]
101+
remove(["a", "b", "c", "d", "e", "f", "g"], 6),
102+
["a", "b", "c", "d", "e", "f"]
111103
);
112104

113105
test(
114106
"formatPercentage function works - case 1",
115-
formatPercentage([23, 18.103, 187.2, 0.372]), [
116-
"23%",
117-
"18.1%",
118-
"100%",
119-
"0.37%"
120-
]
107+
formatPercentage([23, 18.103, 187.2, 0.372]),
108+
["23%", "18.1%", "100%", "0.37%"]
121109
);

mandatory/3-playing-computer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
let x = 2;
1919
let a = 6;
2020

21-
const f1 = function(a, b) {
21+
const f1 = function (a, b) {
2222
return a + b;
2323
};
2424

25-
const f2 = function(a, b) {
25+
const f2 = function (a, b) {
2626
return a + b + x;
2727
};
2828

0 commit comments

Comments
 (0)