You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 17, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/js-core-1/week-4/homework.md
+71-47Lines changed: 71 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,70 @@ title: Coursework
4
4
sidebar_label: Coursework
5
5
---
6
6
7
+
## 0) Flipped Classroom Practice (3h)
8
+
9
+
The video playlist contains some "content" videos and one "practice" video for each content video.
10
+
11
+
0.1 What does the following code do?
12
+
13
+
Can you refactor it so that:
14
+
15
+
- the variables have more understandable names
16
+
- the if statements are rewritten into a function with an understandable name
17
+
- the whole loop is extracted into a reusable function with an understandable name (test the function by calling it with the values `[3, 12, 6, 11, 2]` and also logging the output)
18
+
19
+
```js
20
+
constc= [13, 4, 10, 7, 1];
21
+
constt= [3, 12, 6, 11, 2];
22
+
constn= [];
23
+
for (constkof c) {
24
+
let v = k;
25
+
if (k ===13) {
26
+
v ="K";
27
+
} elseif (k ===12) {
28
+
v ="Q";
29
+
} elseif (k ===11) {
30
+
v ="J";
31
+
} elseif (k ===1) {
32
+
v ="A";
33
+
} else {
34
+
v = k;
35
+
}
36
+
n.push(v);
37
+
}
38
+
39
+
console.log("Your cards are named", n);
40
+
```
41
+
42
+
1.1 Refactor this code to use the `.filter()` array method
43
+
44
+
```js
45
+
constyourCards= [13, 4, 10, 7, 1];
46
+
consttheirCards= [3, 12, 6, 11, 2];
47
+
48
+
functiongetNumberCards(cards) {
49
+
constnumberCards= [];
50
+
for (constcardof cards) {
51
+
if (card >1&& card <11) {
52
+
numberCards.push(card);
53
+
}
54
+
}
55
+
return numberCards;
56
+
}
57
+
58
+
console.log("Your number cards are", getNumberCards(yourCards));
59
+
console.log("Their number cards are", getNumberCards(theirCards));
60
+
```
61
+
62
+
2.1 Refactor the code from 0.1 above even further to use the `.map()` array method.
63
+
64
+
3.1 Using `.filter()` and `.map()`, can you write a program that starts with the same `yourCards` and `theirCards` arrays as above and prints out to the console:
65
+
66
+
```
67
+
Your suit cards are [ 'K', 'A' ]
68
+
Their suit cards are [ 'Q', 'J' ]
69
+
```
70
+
7
71
## 1) Review Solutions for Last Weeks Coursework (30 minutes)
8
72
9
73
You should do this every week from now on. We will stop reminding you soon.
@@ -15,70 +79,30 @@ Once you have access to the solutions repo, review your work compared to the exa
15
79
16
80
Write down your target areas and take them to your buddy group. What does your mentor think? Do they agree with your assessment?
17
81
18
-
## 2) FreeCodeCamp (4 hours)
19
-
20
-
You should complete all of these FreeCodeCamp exercises - https://www.freecodecamp.org/learn
21
-
22
-
- Introduction to the Basic Data Structure Challenges
23
-
- Use an Array to Store a Collection of Data
24
-
- Access an Array's Contents Using Bracket Notation
25
-
- Add Items to an Array with push() and unshift()
26
-
- Remove Items from an Array with pop() and shift()
27
-
- Remove Items Using splice()
28
-
- Add Items Using splice()
29
-
- Copy Array Items Using slice()
30
-
- Copy an Array with the Spread Operator
31
-
- Combine Arrays with the Spread Operator
32
-
- Check For The Presence of an Element With indexOf()
33
-
- Iterate Through All an Array's Items Using For Loops
34
-
- Create complex multi-dimensional arrays
35
-
- Add Key-Value Pairs to JavaScript Objects
36
-
- Modify an Object Nested Within an Object
37
-
- Access Property Names with Bracket Notation
38
-
- Use the delete Keyword to Remove Object Properties
39
-
- Check if an Object has a Property
40
-
- Iterate Through the Keys of an Object with a for...in Statement
41
-
- Generate an Array of All Object Keys with Object.keys()
42
-
- Modify an Array Stored in an Object
43
-
44
-
## 3) JavaScript Exercises (3 hours)
45
-
46
-
Here are a set of exercise that will help you to solidify your knowledge of JavaScript.
47
-
48
-
For this step, open the "Exercises" folder and complete all of the challenges.
In the following scenario imagine you are a recruit for a company and your team leader asks you to write an email requesting a meeting with the Head of Customer Services (HCS). Remember to include the subject line and use appropriate formatting.
83
107
84
-
"HCS has complained about the customer services application to the software team leader. He has found some frustrating problems with the user interface. The team leader told you to go and see the HCS, find out what is wrong and then come back with improvements. The HCS is very busy. You should email requesting a meeting and outline clearly what you need the meeting for."
108
+
"HCS has complained about the customer services application to the software team leader. He has found some frustrating problems with the user interface. The team leader told you to go and see the HCS, find out what is wrong and then come back with improvements. The HCS is very busy. You should email requesting a meeting and outline clearly what you need the meeting for."
Copy file name to clipboardExpand all lines: docs/js-core-1/week-4/mentors.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,10 @@ Want to make a change to this week but don't have the time? Click [here](https:/
8
8
9
9
Want to report a bug in this week? Click [here](https://github.com/CodeYourFuture/syllabus/issues/new?assignees=&labels=bug&template=bug-report.md&title=)
10
10
11
+
## Coursework
12
+
13
+
As an alternative to week 4 coursework, some consolidation on week 3 using array methods could be done.
14
+
11
15
## Questions and Help
12
16
13
17
We highly recommend joining the relevant Slack Channel for this module. In this channel you can ask questions, get advice from previous teachers and discuss lesson content.
@@ -16,6 +20,52 @@ We highly recommend joining the relevant Slack Channel for this module. In this
16
20
17
21
For general Syllabus feedback and help you can post in [cyf-syllabus](https://codeyourfuture.slack.com/archives/C012UUW69S8)
18
22
23
+
## Flipped classroom recap/Q&A
24
+
25
+
The flipped classroom practice should have trainees
26
+
27
+
- Refactor code to pull out meaningfully named functions to represent business logic (e.g. `isShortName` instead of `name.length<7`)
28
+
- Refactor code to use array methods as appropriate instead of `for ... of`
29
+
-`.map()`
30
+
-`.filter()`
31
+
- As bonus, some minimal explanation of named functions, anonymous functions and arrow functions is given -> not all trainees need to understand it at this stage. They should return to the video when they are ready for it/feel the need for it.
32
+
- Note that the following are _not_ currently covered
33
+
-`.forEach()` does not tend to have much value over for ... of, so is not covered
34
+
-`.reduce()` trainees find a lot of code with reduce on the web and typically cannot adequately explain it
35
+
- Not covered but trainees can look up in syllabus or MDN
36
+
-`.includes()`
37
+
-`.sort()`
38
+
- other array methods
39
+
40
+
Some questions/prompts that may be useful
41
+
42
+
- What does this program do? (show programs of varying degrees of complexity using `.map()` and `.filter()`)
43
+
- When do we use `.map()`?
44
+
- When do we use `.filter()`?
45
+
- What is the difference between `arr.filter(isBig)` and `arr.filter(isBig())`?
46
+
- What is the difference between `.map()` and `.filter()`
47
+
- in terms of the result that is output?
48
+
- in terms of the function that must be passed
49
+
- What are some reasons for refactoring expressions into functions that evaluate to the same thing? e.g.
50
+
51
+
```js
52
+
if (cards.length>7) {
53
+
console.log("you have too many cards in your hand");
54
+
}
55
+
```
56
+
57
+
vs
58
+
59
+
```js
60
+
shouldDiscard(cards) {
61
+
returncards.length>7;
62
+
}
63
+
64
+
if (shouldDiscard(cards)) {
65
+
console.log("you have too many cards in your hand");
66
+
}
67
+
```
68
+
19
69
## Presentations (Out of date, for reference only)
0 commit comments