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

Commit 6b86c91

Browse files
committed
first commit
1 parent c961049 commit 6b86c91

File tree

26 files changed

+299
-116
lines changed

26 files changed

+299
-116
lines changed

Week-1/Homework/mandatory/1-writers.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ let writers = [
3838
alive: true
3939
}
4040
];
41-
41+
for(let key in writers){
42+
if(writers[key].alive === true ){
43+
console.log(`Hi, my name is ${writers[key].firstName} ${writers[key].lastName}. I am ${writers[key].age} years old, and work as a ${writers[key].occupation}`);
44+
}
45+
}
4246
/*
4347
If you want an extra challenge, only `console.log()` the writers that are alive.
4448
*/

Week-1/Homework/mandatory/2-water-bottle.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,23 @@ We made a start on this for you here:
1111
let bottle = {
1212
volume: 0,
1313
fill: function() {
14-
// calling this function should make you bottles volume = 100;
14+
calling this function should make you bottles volume = 100;
15+
this.volume = 100;
16+
return this.volume;
17+
1518
},
1619
drink: function() {
17-
// calling this function should decrease your bottles volume by 10;
20+
calling this function should decrease your bottles volume by 10;
21+
this.volume -= 10;
22+
return this.volume;
1823
},
1924
empty: function() {
2025
// this function should return true if your bottles volume = 0
26+
if(this.volume === 0){
27+
return true;
28+
}
2129
}
30+
2231
};
2332

2433
/*

Week-1/Homework/mandatory/3-groceries.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
let groceriesToBuy = [];
77

88
let groceryList = {
9-
item1: "",
10-
item2: "",
11-
item3: ""
9+
item1: "Potatoes",
10+
item2: "Orange Juice",
11+
item3: "Rice"
1212
};
13+
for(let key in groceryList){
14+
groceriesToBuy.push(groceryList[key]);
15+
}
16+
console.log(groceriesToBuy);

Week-1/Homework/projects/1-recipes.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,15 @@ cocoa
2222
2323
**/
2424

25-
let recipes = {};
25+
let recipes = {
26+
title: 'Mole',
27+
servings: 2,
28+
ingredients: ['cinnamon', 'cumin', 'cocoa'],
29+
};
30+
console.log(recipes.title);
31+
console.log(`Serves: ${recipes.servings}`);
32+
console.log(`Ingredients:`);
33+
console.log(recipes.ingredients[0]);
34+
console.log(recipes.ingredients[1]);
35+
console.log(recipes.ingredients[2]);
36+

Week-1/Homework/projects/2-reading-list.js

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,55 @@ If you read it, log a string like 'You already read "The Hobbit" by J.R.R. Tolki
2525
2626
**/
2727

28-
let books = [];
28+
let books = [
29+
{
30+
title: 'To Kill a Mockingbird',
31+
author: 'Harper Lee',
32+
alreadyRead: true,
33+
},
34+
{
35+
title: 'The Great Gatsby',
36+
author: 'F. Scott Fitzgerald',
37+
alreadyRead: false,
38+
},
39+
{
40+
title: 'One Hundred Years of Solitude',
41+
author: 'Gabriel García Márquez',
42+
alreadyRead: true,
43+
},
44+
{
45+
title: 'The Lord of the Rings',
46+
author: 'J.R.R',
47+
alreadyRead: true,
48+
},
49+
{
50+
title: 'Invisible Man',
51+
author: 'Ralph Ellison',
52+
alreadyRead: false,
53+
},
54+
{
55+
title: 'Don Quixote',
56+
author: 'Miguel de Cervantes',
57+
alreadyRead: false,
58+
},
59+
{
60+
title: 'Beloved',
61+
author: 'Toni Morrison',
62+
alreadyRead: true,
63+
},
64+
{
65+
title: 'The Hobbit',
66+
author: 'J.R.R',
67+
alreadyRead: false,
68+
},
69+
];
70+
// for(let value in books){
71+
// console.log(`${books[value].title} by ${books[value].author}.`);
72+
// }
73+
for(let key in books){
74+
if(books[key].alreadyRead === true){
75+
console.log(`You already read ${books[key].title} by ${books[key].author}.`)
76+
}else{
77+
console.log(`You still need to read ${books[key].title} by ${books[key].author}.`)
78+
}
79+
}

Week-1/InClass/A-objects-intro/exercise-part-0.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,21 @@ Describe your own laptop as a JavaScript object
44
55
Try to think of as many properties as you can!
66
7-
*/
7+
*/
8+
let laptop = {
9+
brand: 'Lenovo',
10+
screenSize: 14,
11+
memory: '4-GB',
12+
processor: 'Intel Core i5',
13+
disk: 320,
14+
operatingSystem: 'Linux-Ubuntu',
15+
touchScreen: false,
16+
};
17+
console.log(laptop);
18+
console.log(laptop.brand);
19+
console.log(laptop.screenSize);
20+
console.log(laptop.memory);
21+
console.log(laptop.processor);
22+
console.log(laptop.disk);
23+
console.log(laptop.operatingSystem);
24+
console.log(laptop.touchScreen);

Week-1/InClass/A-objects-intro/exercise-part-1.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,21 @@ can describe with a JavaScript object
66
Assign each of them to a separate variable
77
88
*/
9+
let car = {
10+
make: 'Volkswagon',
11+
model: 'Golf',
12+
year: 2006,
13+
engineSize: '1.9 cc',
14+
color: 'Green',
15+
fuelType: 'Diesel',
16+
automaticGearbox: false,
17+
};
18+
console.log(car);
19+
console.log(car.make);
20+
console.log(car.model);
21+
console.log(car.year);
22+
console.log(car.engineSize);
23+
console.log(car.color);
24+
console.log(car.fuelType);
25+
console.log(car.automaticGearbox);
926

Week-1/InClass/A-objects-intro/exercise-part-2.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ The objects below have some syntax issues - try and fix them all!
55
*/
66

77
let kitten = {
8-
fur colour: "orange",
9-
age "23"
8+
furcolour: "orange",
9+
age: "23"
1010
};
1111

12-
let laptop =
13-
brand: "Lenovo"
14-
ram "5GB"
15-
}
12+
let laptop = {
13+
brand: "Lenovo",
14+
ram: "5GB",
15+
};
1616

1717
let phone = {
18-
operating system "iOS",
18+
'operating system': "iOS",
1919
hasStylus: true,
20-
megapixels 12
21-
"batteryLife": "24 hours"
20+
megapixels: 12,
21+
batteryLife: "24 hours",
22+
};

Week-1/InClass/B-objects-get-set/exercise-1.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ let kitten = {
1010

1111
// YOUR CODE GOES BELOW HERE
1212

13-
13+
console.log(kitten.ageMonths);
14+
console.log(kitten.isFemale);
15+
console.log(kitten.furColour);
1416

1517

1618

Week-1/InClass/B-objects-get-set/exercise-2.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
*/
66

77
let phone = {
8-
brand: 'iPhone,
9-
model 'iPhone X'
8+
brand: 'iPhone',
9+
model: 'iPhone X',
1010
launchYear: 2017,
11-
is Unlocked: true
12-
;
11+
isUnlocked: true
12+
};
1313

14-
let phoneBrand = phone.bbrand;
15-
let phoneLaunchYear = phone[launchYear];
14+
let phoneBrand = phone.brand;
15+
let phoneLaunchYear = phone.launchYear;
1616

1717
// DO NOT MODIFY BELOW THIS LINE
1818

0 commit comments

Comments
 (0)