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

Commit 4df079d

Browse files
committed
Move some exercises to manadatory
The manadatory exercises didn't include some concepts that were covered in the lesson, so I've just moved some of the in-class exercises into the mandatory section. Looks like the exercises in the syllabus don't match the in-class exercises now anyway
1 parent c73295b commit 4df079d

File tree

9 files changed

+113
-128
lines changed

9 files changed

+113
-128
lines changed

1-exercises/A-array-find/exercise.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

1-exercises/F-array-forEach/exercise.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

1-exercises/G-array-methods/exercise2.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

1-exercises/H-array-methods-2/exercise2.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

1-exercises/H-array-methods-2/exercise3.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

mandatory/1-create-functions.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ Write a function that:
4242

4343
function formatPercentage() {}
4444

45+
/*
46+
Write a function that:
47+
- Takes an array as a parameter
48+
- Returns the *first* name which starts with A and is longer than 7 letters.
49+
*/
50+
51+
function findLongNameThatStartsWithA() {}
52+
4553
/*
4654
===================================================
4755
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
@@ -145,3 +153,19 @@ test("formatPercentage function works", () => {
145153
"0.37%",
146154
]);
147155
});
156+
157+
test("findLongNameThatStartsWithA function works", () => {
158+
expect(
159+
findLongNameThatStartsWithA([
160+
"Rakesh",
161+
"Antonio",
162+
"Alexandra",
163+
"Andronicus",
164+
"Annam",
165+
"Mikey",
166+
"Anastasia",
167+
"Karim",
168+
"Ahmed",
169+
])
170+
).toEqual("Alexandra");
171+
});

mandatory/10-capitalize.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Write a function that accepts a string as a parameter and returns a string where the first letter of the input string is uppercase.
3+
For example, capitalize("hello") should return "Hello"
4+
Tip: use the string method .split() and the array method .join()
5+
*/
6+
7+
function capitalize(str) {}
8+
9+
/*
10+
===================================================
11+
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
12+
There are some Tests in this file that will help you work out if your code is working.
13+
To run the tests for just this one file, type `npm test -- --testPathPattern 10-capitalize` into your terminal
14+
(Reminder: You must have run `npm install` one time before this will work!)
15+
===================================================
16+
*/
17+
18+
test("Capitalize works - case 1", () => {
19+
expect(capitalize("hello")).toEqual("Hello");
20+
});
21+
22+
test("Capitalize works - case 2", () => {
23+
expect(capitalize("daniel")).toEqual("Daniel");
24+
});
25+
26+
test("Capitalize works - case 2", () => {
27+
expect(capitalize("ivina")).toEqual("Ivina");
28+
});

mandatory/11-is-in-uk.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Write a function that accepts a name of a country as a string and returns true or false whether the country is in the UK.
3+
*/
4+
5+
const ukNations = ["Scotland", "Wales", "England", "Northern Ireland"];
6+
7+
function isInUK(country) {}
8+
9+
/*
10+
===================================================
11+
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
12+
There are some Tests in this file that will help you work out if your code is working.
13+
To run the tests for just this one file, type `npm test -- --testPathPattern 11-is-in-uk` into your terminal
14+
(Reminder: You must have run `npm install` one time before this will work!)
15+
===================================================
16+
*/
17+
18+
test("isInUK works - case 1", () => {
19+
expect(isInUK("France")).toEqual(false);
20+
});
21+
22+
test("isInUK works - case 2", () => {
23+
expect(isInUK("Republic of Ireland")).toEqual(false);
24+
});
25+
26+
test("isInUK works - case 3", () => {
27+
expect(isInUK("England")).toEqual(true);
28+
});

mandatory/9-group-people.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Write a function that accepts two arrays as parameters:
3+
1. An array of volunteer names
4+
2. An array of trainee names
5+
6+
The function should return a single array containing *both* the volunteers and trainee names.
7+
*/
8+
9+
function groupPeople() {}
10+
11+
/*
12+
===================================================
13+
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
14+
There are some Tests in this file that will help you work out if your code is working.
15+
To run the tests for just this one file, type `npm test -- --testPathPattern 2-oxygen-levels` into your terminal
16+
(Reminder: You must have run `npm install` one time before this will work!)
17+
===================================================
18+
*/
19+
20+
TestScheduler("volunteersAndTrainees works", () => {
21+
let volunteers = ["Daniel", "Irina", "Rares"];
22+
let trainees = ["Rukmini", "Abdul", "Austine", "Swathi"];
23+
24+
expect(groupPeople(volunteers, trainees)).toEqual([
25+
"Daniel",
26+
"Irina",
27+
"Rares",
28+
"Rukmini",
29+
"Abdul",
30+
"Austine",
31+
"Swathi",
32+
]);
33+
});

0 commit comments

Comments
 (0)