diff --git a/Week1/Js-exercises/1-hello-world.js b/Week1/Js-exercises/1-hello-world.js new file mode 100644 index 000000000..fb44b13fc --- /dev/null +++ b/Week1/Js-exercises/1-hello-world.js @@ -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"); \ No newline at end of file diff --git a/Week1/Js-exercises/10-compare-arrays.js b/Week1/Js-exercises/10-compare-arrays.js new file mode 100644 index 000000000..0adfe88e2 --- /dev/null +++ b/Week1/Js-exercises/10-compare-arrays.js @@ -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"); +} \ No newline at end of file diff --git a/Week1/Js-exercises/2-error-debugging.js b/Week1/Js-exercises/2-error-debugging.js new file mode 100644 index 000000000..29cecbbd3 --- /dev/null +++ b/Week1/Js-exercises/2-error-debugging.js @@ -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. \ No newline at end of file diff --git a/Week1/Js-exercises/3-log-the-number.js b/Week1/Js-exercises/3-log-the-number.js new file mode 100644 index 000000000..642dde0a6 --- /dev/null +++ b/Week1/Js-exercises/3-log-the-number.js @@ -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); diff --git a/Week1/Js-exercises/4-log-the-string.js b/Week1/Js-exercises/4-log-the-string.js new file mode 100644 index 000000000..b3d2f9ebc --- /dev/null +++ b/Week1/Js-exercises/4-log-the-string.js @@ -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); diff --git a/Week1/Js-exercises/5-round-a-number.js b/Week1/Js-exercises/5-round-a-number.js new file mode 100644 index 000000000..86f4d0ea1 --- /dev/null +++ b/Week1/Js-exercises/5-round-a-number.js @@ -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); \ No newline at end of file diff --git a/Week1/Js-exercises/6-array-of-animals.js b/Week1/Js-exercises/6-array-of-animals.js new file mode 100644 index 000000000..ff8413b5d --- /dev/null +++ b/Week1/Js-exercises/6-array-of-animals.js @@ -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); diff --git a/Week1/Js-exercises/7-length-of-a-string.js b/Week1/Js-exercises/7-length-of-a-string.js new file mode 100644 index 000000000..8b06011e9 --- /dev/null +++ b/Week1/Js-exercises/7-length-of-a-string.js @@ -0,0 +1,4 @@ + +"use strict"; +const mySentence = "Programming is so interesting!"; +console.log(mySentence.length); diff --git a/Week1/Js-exercises/8-type-checker.js b/Week1/Js-exercises/8-type-checker.js new file mode 100644 index 000000000..54bad6823 --- /dev/null +++ b/Week1/Js-exercises/8-type-checker.js @@ -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); +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") +}; diff --git a/Week1/Js-exercises/9-log-the-remainder.js b/Week1/Js-exercises/9-log-the-remainder.js new file mode 100644 index 000000000..0a1731173 --- /dev/null +++ b/Week1/Js-exercises/9-log-the-remainder.js @@ -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);