Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c5d3cb8
In Class A-Objects-Intro exercise Completed.
AliHaider-1 Jul 26, 2020
d331db2
In Class A-objects-intro exercise part 1 completed
AliHaider-1 Jul 26, 2020
2df2e1d
In Class A-objects-intro exercise part 2 completed
AliHaider-1 Jul 26, 2020
ba04712
In Class B-objects-get-set exercise 1 completed.
AliHaider-1 Jul 26, 2020
9aa9eda
In Class B-objects-get-set exercise 2 completed
AliHaider-1 Jul 26, 2020
ee010e7
In Class B-objects-get-set exercise 3 completed
AliHaider-1 Jul 26, 2020
16869cd
In Class B-objects-get-set exercise 4 completed
AliHaider-1 Jul 26, 2020
ee72b0e
In Class C-more-complex-objects exercise 1 completed
AliHaider-1 Jul 26, 2020
233a018
In Class C-more-complex-objects exercise 2 completed
AliHaider-1 Jul 26, 2020
072bb29
In Class C-more-complex-objects
AliHaider-1 Jul 26, 2020
cb9e37d
In Class D-methods exercise 1 completed
AliHaider-1 Jul 26, 2020
3c96c4b
In Class D-methods exercise 2 completed.
AliHaider-1 Jul 26, 2020
41808f7
In Class D-methods exercise 3 completed.
AliHaider-1 Jul 26, 2020
ddbe831
In Class D-methods exercise 4 completed.
AliHaider-1 Jul 26, 2020
eb51520
In Class D-methods exercise 5 completed.
AliHaider-1 Jul 26, 2020
dfe348b
In Class E-arrays-of-objets exercise completed.
AliHaider-1 Jul 26, 2020
4c91b0c
In Class E-arrays-of-objects excersise completed.
AliHaider-1 Jul 28, 2020
3c159a4
In Class E-arrays-of-objects exercise 3 completed.
AliHaider-1 Jul 28, 2020
db46af6
In Class F-object-keys exercise part 0 completed.
AliHaider-1 Jul 28, 2020
4d9ff9f
In Class F-object-keys exercise part 1 completed.
AliHaider-1 Jul 28, 2020
aef87bb
In Class F-object-keys exercise part 2 completed
AliHaider-1 Jul 28, 2020
003278e
mandatory 1-writers exercise completed
AliHaider-1 Jul 28, 2020
caad178
mandatory 2-water-bottle exercise completed.
AliHaider-1 Jul 28, 2020
1b54128
mandatory 3-groceries exercise completed.
AliHaider-1 Jul 28, 2020
0199346
Projects 1-recipes exercise completed
AliHaider-1 Jul 28, 2020
65abe61
projects 2-reading-list exercise completed.
AliHaider-1 Jul 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\Week-1\\InClass\\E-arrays-of-objects\\exercise-3.js"
}
]
}
10 changes: 10 additions & 0 deletions Week-1/Homework/mandatory/1-writers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ let writers = [
/*
If you want an extra challenge, only `console.log()` the writers that are alive.
*/

function getwriters(writers){
if(writers.alive){
return "Hi, my name is " + writers.firstName + " " + writers.lastName+". I am "+writers.age+" years old, and work as a "+writers.occupation+".";
} else {
return false;
}
}

console.log(writers.map(getwriters).filter(Boolean));
9 changes: 5 additions & 4 deletions Week-1/Homework/mandatory/2-water-bottle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ We made a start on this for you here:
let bottle = {
volume: 0,
fill: function() {
// calling this function should make you bottles volume = 100;
return this.volume =100;// calling this function should make you bottles volume = 100;
},
drink: function() {
// calling this function should decrease your bottles volume by 10;
return this.volume=this.volume-10;// calling this function should decrease your bottles volume by 10;
},
empty: function() {
// this function should return true if your bottles volume = 0
}
if (this.volume===0){
return true;// this function should return true if your bottles volume = 0
}}
};

/*
Expand Down
10 changes: 10 additions & 0 deletions Week-1/Homework/mandatory/3-groceries.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ let groceryList = {
item2: "",
item3: ""
};

groceryList.item1 = "Potatoes";
groceriesToBuy.push(groceryList.item1);
groceryList.item2 = "Orange Juice";
groceriesToBuy.push(groceryList.item2);
groceryList.item3 = "Rice";
groceriesToBuy.push(groceryList.item3);


console.log(groceriesToBuy);
18 changes: 17 additions & 1 deletion Week-1/Homework/projects/1-recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@ cocoa

**/

let recipes = {};
let recipes = {
Name : "Mole",
Serving: 2,
Ingredients: {
a:"cinnamon",
b:"cumin",
c:"cocoa"
}
};


console.log( `${recipes.Name}
Serves: ${recipes.Serving}
Ingredients:
${recipes.Ingredients.a}
${recipes.Ingredients.b}
${recipes.Ingredients.c}`);
26 changes: 25 additions & 1 deletion Week-1/Homework/projects/2-reading-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,28 @@ If you read it, log a string like 'You already read "The Hobbit" by J.R.R. Tolki

**/

let books = [];
let books = [
{
title: "The Hobbit",
Author: "J.R.R Tolkien",
alreadyRead: true
},
{
title: "The Lord of Rings",
Author: "J.R.R Tolkien",
alreadyRead: false
}

];

// function getTitleAuthor (books){
// return books.title+" by "+books.Author;
// }
books.forEach(function getTitleAuthor(books) {
if(books.alreadyRead){
console.log("You already read "+ books.title + " by " + books.Author);
}
else {
console.log("You still need to read "+books.title + " by " + books.Author);
}
});
12 changes: 11 additions & 1 deletion Week-1/InClass/A-objects-intro/exercise-part-0.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@ Describe your own laptop as a JavaScript object

Try to think of as many properties as you can!

*/
*/

let laptop = {
brand : "HP",
screenSize : 15,
isTouchscreen : false,
ramMemorysize : 8,
storageMemorysize : 250
};

console.log(laptop);
51 changes: 51 additions & 0 deletions Week-1/InClass/A-objects-intro/exercise-part-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,55 @@ can describe with a JavaScript object
Assign each of them to a separate variable

*/
// 1
let smartPhone ={
brand : "Samsung",
color : "blue",
memory : 64,
};

let phone = smartPhone;

console.log(phone);
//2
let newShirt = {
size : 15,
color : "blue",
type : "cotton"
};

let shirt = newShirt;

console.log(shirt);
//3
let whiteBoard = {
size : "4ft x 4ft",
color : "white",
type : "magnetic"
}

let writingBoard = whiteBoard;

console.log(writingBoard);
//4

let newDesk = {
height : 4,
width : 5,
type : "Oak",
color : "white"
}

let desk = newDesk;

console.log(desk);
//5

let newMonitor = {
brand : "samsung",
screenSize : 24,
type : "smart",
}
let monitor = newMonitor;

console.log(monitor);
19 changes: 10 additions & 9 deletions Week-1/InClass/A-objects-intro/exercise-part-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ The objects below have some syntax issues - try and fix them all!
*/

let kitten = {
fur colour: "orange",
age "23"
"fur colour": "orange",
age : "23"
};

let laptop =
brand: "Lenovo"
ram "5GB"
}
let laptop = {
brand: "Lenovo",
ram : "5GB"
};

let phone = {
operating system "iOS",
"operating system" : "iOS",
hasStylus: true,
megapixels 12
"batteryLife": "24 hours"
megapixels : 12,
batteryLife: "24 hours"
};
18 changes: 6 additions & 12 deletions Week-1/InClass/B-objects-get-set/exercise-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
Console.log the values of each property of "kitten"
*/

let kitten = {
ageMonths: 3,
isFemale: true,
furColour: "brown"
};

let kitten = {
// YOUR CODE GOES BELOW HERE






isFurry : true,
color : "gray",
}
console.log(kitten.isFurry);
console.log(kitten.color);
// YOUR CODE GOES ABOVE HERE
12 changes: 6 additions & 6 deletions Week-1/InClass/B-objects-get-set/exercise-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/

let phone = {
brand: 'iPhone,
model 'iPhone X'
brand: 'iPhone',
model :'iPhone X',
launchYear: 2017,
is Unlocked: true
;
"is Unlocked": true
};

let phoneBrand = phone.bbrand;
let phoneLaunchYear = phone[launchYear];
let phoneBrand = phone.brand;
let phoneLaunchYear = phone["launchYear"];

// DO NOT MODIFY BELOW THIS LINE

Expand Down
3 changes: 3 additions & 0 deletions Week-1/InClass/B-objects-get-set/exercise-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
*/

// WRITE CODE BELOW THIS
let kitten = {
name : "Gilbert"
};

// WRITE CODE ABOVE THIS

Expand Down
3 changes: 2 additions & 1 deletion Week-1/InClass/B-objects-get-set/exercise-4.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ let dog = {
};

// WRITE CODE BELOW THIS LINE

dog.name = "Rex";
dog.wantsToPlay = true;


// WRITE CODE ABOVE THIS LINE
Expand Down
3 changes: 3 additions & 0 deletions Week-1/InClass/C-more-complex-objects/exercise-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ let house = {
*/

// - change the address of "house" to '51 Berkley Road'
house.address = '51 Berkley Road.';
// - change the previous owners of "house" to ["Brian M.", "Fiona S."]
house.previousOwners = ["Brian M.", " Fiona S."];
// - change the last name of the current owner of "house" to "Montgomery"
house.currentOwner.lastName = "Montgomery.";


/*
Expand Down
3 changes: 3 additions & 0 deletions Week-1/InClass/C-more-complex-objects/exercise-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ let newCurrentOwner = {
*/

// - assign the value of the variable 'newCurrentOwner' as the value to the house's "currentOwner"
house.currentOwner = newCurrentOwner;
// - from the list of previous owners, replace only "John A." with "Stephen B."
house.previousOwners[1]= " Stephen B.";
// - give the house a new property called 'isForSale' with the value 'false'
house.isForSale = 'false';



Expand Down
14 changes: 11 additions & 3 deletions Week-1/InClass/C-more-complex-objects/exercise-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,25 @@ let parkAvenueHouse = {

// returns the full name (first name + last name) of the owner of the house
function getOwnerFullName(house) {

return house.currentOwner.firstName+ " "+house.currentOwner.lastName;
}

// returns an array of the owners' email addresses of the two houses
function getEmailAddresses(house1, house2) {

let arr = [];
arr.push(house1.currentOwner.email);
arr.push(house2.currentOwner.email);
return arr;
}

// returns the address for the cheapest house out of the two
function getCheapestAddress(house1, house2) {

if(house1.price>house2.price){
return house2.address;
}
else {
return house1.address;
}
}


Expand Down
5 changes: 4 additions & 1 deletion Week-1/InClass/D-methods/exercise-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ Add a method "greet" so this person can say hello.

let person = {
name: "Alice",
age: 25
age: 25,
greet: function(){
return "Hello everybody";
}
};


Expand Down
5 changes: 4 additions & 1 deletion Week-1/InClass/D-methods/exercise-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ Hint: use 'this' keyword to access the name property.

let person = {
name: "Alice",
age: 25
age: 25,
sayName(){
return "My name is "+this.name;
}
};


Expand Down
8 changes: 4 additions & 4 deletions Week-1/InClass/D-methods/exercise-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ let person = {
name: "Alice",
age: 25,
currentAddress: "Glasgow",
changeAddress: (newAddress) {
currentAddress = newAddress;
changeAddress: function (newAddress) {
person.currentAddress = newAddress;
},
celebrateBirthday: function {
that.age = that.age + 1;
celebrateBirthday: function () {
this.age = this.age + 1;
}
};

Expand Down
5 changes: 4 additions & 1 deletion Week-1/InClass/D-methods/exercise-4.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ Define a method "makeFriend" to add a new friend to her list.

let person = {
name: "Alice",
friends: ["John", "Nina"]
friends: ["John", "Nina"],
makeFriend(friend){
return person.friends.push(friend);
}
};


Expand Down
Loading