Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
14 changes: 14 additions & 0 deletions Week1/Js-exercises/1-hello-world.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

"use strict";
console.log("Hello World");
console.log("����� �������");
console.log("Hallo Wereld");
console.log("Merhaba D�nya");
console.log("Silav Dunya")
console.log("Halo Dunia");
console.log("Hola Mundo");
console.log("Ciao Mundo");
console.log("Hei Verden");
console.log("Dia duit ar domhan");
console.log("Hallo wr�ld");
console.log("Bonjou mond lan");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

13 changes: 13 additions & 0 deletions Week1/Js-exercises/10-compare-arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

"use strict";
const arr1 = ["Spring" , "Summer" , "Autumn" , "Winter"];
const arr2 = ["Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"];

console.log("The first array's length is " + arr1.length);
console.log("The second array's length is " + arr2.length);

if(arr1.length === arr2.length){
console.log("They are the same!");
}else {
console.log("Two different sizes");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

4 changes: 4 additions & 0 deletions Week1/Js-exercises/2-error-debugging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"use strict";
/* console.log('I'm awesome'); will not work because we need to escape the single quotation
mark we need to use \ character. */
console.log('I\'m awesome'); //will work fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

7 changes: 7 additions & 0 deletions Week1/Js-exercises/3-log-the-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
let numberX;
console.log("I think x is undefined");
console.log(x);
x = 84;
console.log("now x should be 26");
console.log(x);
Comment thread
MA-Hussein marked this conversation as resolved.
Resolved
8 changes: 8 additions & 0 deletions Week1/Js-exercises/4-log-the-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";
let myString;
myString = "Muhammad Hussein";
console.log("The value of the string will be my name as I wrote it.");
console.log(myString);
myString = "Muhammad"
console.log("my first name will be the result.");
console.log(myString);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

19 changes: 19 additions & 0 deletions Week1/Js-exercises/5-round-a-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";
let z;
z = 7.25;
console.log(z);

let a;
a = Math.round(z);
console.log(a);


let newVariable;

if(z > a){
newVariable = z;
}else {
newVariable = a;
};

console.log(newVariable);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 but you could also explore using conditional operators for assigning value to newVariable as this is a good case of using them

8 changes: 8 additions & 0 deletions Week1/Js-exercises/6-array-of-animals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";
let animalsArr;
console.log("I think the value will be undefined");
console.log(animalsArr);
let favoriteAnimals = ["Hamsters", "Cats", "Dogs",];
console.log(favoriteAnimals);
favoriteAnimals.push("Horses");
console.log(favoriteAnimals);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use const instead of let here 🙂

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

4 changes: 4 additions & 0 deletions Week1/Js-exercises/7-length-of-a-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

"use strict";
let mySentence = "Programming is so interesting!";
console.log(mySentence.length);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const instead of let here as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

62 changes: 62 additions & 0 deletions Week1/Js-exercises/8-type-checker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

"use strict";
let var1 = "customers";
let var2 = "suppliers";
let var3 = {storeName:"mainStore",storeId:001};
let var4 = {itemName:"laptop",itemId:0200};


console.log(typeof var1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for implementation but you could use const instead of let here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

console.log(typeof var3);

if (typeof var1 === typeof var2){
console.log("These two variables have the same type");

}else {
console.log("They are not the same type");
};

if (typeof var1 === typeof var3){
console.log("These two variables have the same type");

}else {
console.log("They are not the same type");
};

if (typeof var1 === typeof var4){
console.log("These two variables have the same type");

}else {
console.log("They are not the same type");
};

if (typeof var2 === typeof var3){
console.log("These two variables have the same type");

}else {
console.log("They are not the same type");
};

if (typeof var2 === typeof var4){
console.log("These two variables have the same type");

}else {
console.log("They are not the same type");
};

if (typeof var3 === typeof var4){
console.log("These two variables have the same type");

}else {
console.log("They are not the same type");
};

if (typeof var1 !== typeof var3){
console.log("They are not the same type");
};

if (typeof var1 !== typeof var2){
console.log("They are not the same type");
}else {
console.log("These two variables have the same type")
};
11 changes: 11 additions & 0 deletions Week1/Js-exercises/9-log-the-remainder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

let x = 7;
x = x % 3 ; // new value of x will be 1 as it's remainder when it's divided by three is 1.
console.log(x); // we will see it is 1.

let y = 21; // Their value would be the same.Because we didn't assign a new value to them.
let z = 13;

console.log(y); /* We can see they still have their initial values.
Because the remainder includes x but not y and z.*/
console.log(z);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄. There was an error in the homework which David corrected this morning. Would you like to revisit?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated according to the homework updates . Thanks a lot Ysah for your helpful comments .