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 all 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
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
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
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 84");
console.log(x);
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
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
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";
const animalsArr;
console.log("I think the value will be undefined");
console.log(animalsArr);
const favoriteAnimals = ["Hamsters", "Cats", "Dogs",];
console.log(favoriteAnimals);
favoriteAnimals.push("Horses");
console.log(favoriteAnimals);
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";
const mySentence = "Programming is so interesting!";
console.log(mySentence.length);
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";
const var1 = "customers";
const var2 = "suppliers";
const var3 = {storeName:"mainStore",storeId:001};
const var4 = {itemName:"laptop",itemId:0200};


console.log(typeof var1);
Copy link
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
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 ; // the 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; // the new value of y will be 1 .
let z = 13; // the new value of z will be 1 .

console.log(y);

console.log(z);