Skip to content
Prev Previous commit
Next Next commit
JS1 Week1 exercises
  • Loading branch information
GMouzakis committed Feb 2, 2020
commit 949f05766a72eaef6fc4584e0952ac64672e9c61
9 changes: 9 additions & 0 deletions Week1/homework/js-exercises/JS1_w1e10_arrCompare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

const arr1 = [123,234,0,1];
const arr2 = [192,168,1,1,8080];

console.log("The length of the arr1 is " + arr1.length + " and the length of the arr2 is " + arr2.length);

if(arr1.length === arr2.length) console.log("arr1 and arr2 has the same length");
else console.log("arr1 and arr2 has not the same length");
9 changes: 9 additions & 0 deletions Week1/homework/js-exercises/JS1_w1e6_logTheAnimals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

let myArr = new Array;
console.log("Now myArr variable is an array without elements or an empty array");
console.log(myArr);
let animalsCollection = ["spider","scorpion","mantis"];
console.log(animalsCollection);
animalsCollection.push("Piglet");
console.log(animalsCollection);
4 changes: 4 additions & 0 deletions Week1/homework/js-exercises/JS1_w1e7_stringLength.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);
21 changes: 21 additions & 0 deletions Week1/homework/js-exercises/JS1_w1e8_typeChecker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'

let str1 = "hi";
let str2 = "there";
let num1 = 1;
let num2 = 2;

console.log(typeof str1, typeof str2, typeof num1, typeof num2);

console.log("str1 and str2 has ");
if (typeof str1 === typeof str2) console.log("the same type"); else console.log("not the same type");
console.log("str1 and num1 has ");
if (typeof str1 === typeof num1) console.log("the same type"); else console.log("not the same type");
console.log("str1 and num2 has ");
if (typeof str1 === typeof num2) console.log("the same type"); else console.log("not the same type");
console.log("str2 and num1 has ");
if (typeof str2 === typeof num1) console.log("the same type"); else console.log("not the same type");
console.log("str2 and num2 has ");
if (typeof str2 === typeof num2) console.log("the same type"); else console.log("not the same type");
console.log("num1 and num2 has ");
if (typeof num1 === typeof num2) console.log("the same type"); else console.log("not the same type");
8 changes: 8 additions & 0 deletions Week1/homework/js-exercises/JS1_w1e9_remainderLog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'

let x = 7;
console.log("x is 7 and after the 'x = x % 3' calculation, the x will be " + (x % 3));
let y = 21;
console.log("y is 21 and after the 'y = y % 4' calculation, the y will be " + (y % 4));
let z = 13;
console.log("z is 13 and after the 'z = z % 2' calculation, the z will be " + (y % 2));