Skip to content

Commit 21844dc

Browse files
committed
Inital commit
0 parents  commit 21844dc

File tree

102 files changed

+4006
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4006
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## CodeWars Exercises
2+
3+
Complete the following CodeWars exercises. Go to the webpages below and follow the instructions there.
4+
5+
Click "ATTEMPT" to test your solution.
6+
7+
Exercises:
8+
9+
- [Fix my Method](https://www.codewars.com/kata/558710234f02dcc4a8000005)
10+
- [Regular Ball Super Ball](https://www.codewars.com/kata/53f0f358b9cb376eca001079/train/javascript)
11+
12+
## Reading
13+
14+
1.['You Don't Know JS: this & Object Prototypes' - Chapter 3, 'Objects'](https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/this%20%26%20object%20prototypes/ch3.md)
15+
16+
2. Eloquent JavaScript Chapter 4 - 'Data Structures: Objects and Arrays': https://eloquentjavascript.net/04_data.html
17+
3. Eloquent JavaScript Chapter 6 - 'The Secret Life of Objects': https://eloquentjavascript.net/06_object.html
18+
19+
## Viewing
20+
21+
1. [Methods and 'this' keyword in JavaScript](https://www.youtube.com/watch?v=0wN-L9CG3y0)
22+
2. [Modern JavaScript Tutorial #5 - Objects](https://www.youtube.com/watch?v=X0ipw1k7ygU)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Classwork
2+
3+
Firstly, complete any exercises you did not complete during class. They are essential practice for the rest of the homework tasks.
4+
5+
If you get stuck, reach out to your classmates on Slack for help!
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* Challenge 1: Famous Writers
2+
Did you know you can also have an array of objects? We've created one for you here. Loop through the array,
3+
and for each object, `console.log()` out the sentence:
4+
5+
"Hi, my name is {firstName} {lastName}. I am {age} years old, and work as a {occupation}."
6+
7+
Here is the array:
8+
9+
*/
10+
11+
let writers = [
12+
{
13+
firstName: "Virginia",
14+
lastName: "Woolf",
15+
occupation: "writer",
16+
age: 59,
17+
alive: false
18+
},
19+
{
20+
firstName: "Zadie",
21+
lastName: "Smith",
22+
occupation: "writer",
23+
age: 41,
24+
alive: true
25+
},
26+
{
27+
firstName: "Jane",
28+
lastName: "Austen",
29+
occupation: "writer",
30+
age: 41,
31+
alive: false
32+
},
33+
{
34+
firstName: "bell",
35+
lastName: "hooks",
36+
occupation: "writer",
37+
age: 64,
38+
alive: true
39+
}
40+
];
41+
42+
/*
43+
If you want an extra challenge, only `console.log()` the writers that are alive.
44+
*/
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Create an object that acts like a water bottle.
3+
It will need a volume key to store how full or empty the bottle is.
4+
It will be 100 when full and 0 when empty.
5+
Give your water bottle methods for filling it up,
6+
drinking some of it, and emptying it.
7+
8+
We made a start on this for you here:
9+
*/
10+
11+
let bottle = {
12+
volume: 0,
13+
fill: function() {
14+
// calling this function should make you bottles volume = 100;
15+
},
16+
drink: function() {
17+
// calling this function should decrease your bottles volume by 10;
18+
},
19+
empty: function() {
20+
// this function should return true if your bottles volume = 0
21+
}
22+
};
23+
24+
/*
25+
--TIP--
26+
27+
Remember that for changing properties on the current object inside one of its
28+
methods you can refer to it by its variable name: `bottle`.
29+
30+
Once you have completed your object run the following and see if your answer
31+
matches the expected result at the bottom :)
32+
*/
33+
34+
bottle.fill();
35+
bottle.drink();
36+
bottle.drink();
37+
bottle.drink();
38+
if (!bottle.empty()) {
39+
console.log(`bottles volume = ${bottle.volume}`);
40+
}
41+
console.log("Above volume should be: 70");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// You're going shopping, and you need a shopping list.
2+
// 1. Update your groceryList with the items you need: Potatoes, Orange Juice and Rice.
3+
// 2. Loop through the groceryList object to gather the item properties into the groceriesToBuy array.
4+
// 3. Then use console.log() to print out the list. It should print ['Potatoes', 'Orange Juice', 'Rice']
5+
6+
let groceriesToBuy = [];
7+
8+
let groceryList = {
9+
item1: "",
10+
item2: "",
11+
item3: ""
12+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Reading
2+
3+
- [Understanding JavaScript Constructors](https://css-tricks.com/understanding-javascript-constructors/)
4+
5+
## CodeWars Exercises
6+
7+
Complete the following CodeWars exercises. Go to the webpages below and follow the instructions there.
8+
9+
Click "ATTEMPT" to test your solution.
10+
11+
Exercises:
12+
13+
- [Training JS #5: Basic data types--Object](https://www.codewars.com/kata/571f1eb77e8954a812000837/train/javascript)
14+
- [Welcome!](https://www.codewars.com/kata/welcome/train/javascript)
15+
- [Crash Override](https://www.codewars.com/kata/crash-override/train/javascript)
16+
- [Job Matching #1](https://www.codewars.com/kata/56c22c5ae8b139416c00175d/train/javascript)
17+
- [Split the Bill](https://www.codewars.com/kata/5641275f07335295f10000d0/train/javascript)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### Objects
2+
3+
Objects in the real world have properties that describe how they are unique. Your laptop, for example, has a brand (Lenovo/Apple etc.), a screen size (13/15 inch), RAM (8/16GB) etc.
4+
5+
How would we describe the above laptop as a JavaScript object?
6+
7+
```js
8+
let laptop = {
9+
brand: "Lenovo",
10+
screenSize: 13,
11+
isTouchscreen: true
12+
};
13+
```
14+
15+
Useful words to remember when talking about objects:
16+
- **object literal**: anything that has a set of `{...}` around a set of properties is an object literal
17+
- **property** or **key**: `brand`, `screenSize` and `isTouchScreen` are properties/keys of the object
18+
- **values**: `"Lenovo"`, `13` and `true` are values of the object's properties
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
3+
Describe your own laptop as a JavaScript object
4+
5+
Try to think of as many properties as you can!
6+
7+
*/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
3+
Think of 5 different real world "things" that you
4+
can describe with a JavaScript object
5+
6+
Assign each of them to a separate variable
7+
8+
*/
9+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
3+
The objects below have some syntax issues - try and fix them all!
4+
5+
*/
6+
7+
let kitten = {
8+
fur colour: "orange",
9+
age "23"
10+
};
11+
12+
let laptop =
13+
brand: "Lenovo"
14+
ram "5GB"
15+
}
16+
17+
let phone = {
18+
operating system "iOS",
19+
hasStylus: true,
20+
megapixels 12
21+
"batteryLife": "24 hours"

0 commit comments

Comments
 (0)