Thanks to visit codestin.com
Credit goes to github.com

Skip to content

javaScript-1 home work week-1 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions Week1/homework/js-exercises/compareArrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'
const aray1 = ["hello", 123, true,{ name:"Noer"}];
var cars = ["Volvo","Toyota","Fiat","Mercedes","BMW","Saab","Ford"];
// the method to obtain array length is ' length()'.
console.log('The length of the array "arrayy1" is :' + (aray1.length));
console.log('And the length of the array "cars" is :' + (cars.length));
if(cars.length == aray1.length){
console.log("They are the same!");
} else{
console.log("Two different Sizes");
}
3 changes: 3 additions & 0 deletions Week1/homework/js-exercises/errorDebugging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict'
console.log('I'am awesome');
console.log("I'am awesome");
3 changes: 3 additions & 0 deletions Week1/homework/js-exercises/lengthStrings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict'
var mySentence = "Programming is so interesting";
console.log("The String length of the string " + '"' + mySentence + '"' + "is: " + `${mySentence.length}`);
8 changes: 8 additions & 0 deletions Week1/homework/js-exercises/logArray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'
var cars = [];
console.log("The array has no items to display or it is an empty array ");
console.log(cars);
var animals = ["Cow","Donkey","Sheep"];
console.log("An array of three animals : " + animals);
animals.push("Piglet");
console.log("Array of animals after a 'Piglet' is added to it : " + animals);
11 changes: 11 additions & 0 deletions Week1/homework/js-exercises/logHello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'
console.log("Hello World!");
console.log("Geia, sou Kosme!");/* Greek */
console.log("Ni hao, shijie!");/* chinese */
console.log("Bonjour ,le monde!");/* French */
console.log("Privet, mir!")/*Russian*/
console.log("שלום ;עולם!")/*Hebrew*/
console.log("Salamu, Dunia!")/*swahili*/
console.log("ሰላም፤ ዓለም!")/*Amharic*/
console.log("Hallo, Welt!")/*German*/
console.log("Ciao, mondo!");/* Italy*/
7 changes: 7 additions & 0 deletions Week1/homework/js-exercises/logNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'
var numberX;
console.log("Enter an Integer Number:");
console.log('7');
var numberX = 7;
console.log("The value the variable numberX is:");
console.log(numberX);
12 changes: 12 additions & 0 deletions Week1/homework/js-exercises/logRemainder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'
var x = 7;
x = x % 3;
console.log("The result of 'x = x % 3' is:")
console.log(x);
// i used modulo operator to obtain
//the remainder when 7 is divided by 3
var y = 21;
y = y % 4;
console.log(`The remainder of 21 divided by 4 is: ${21 % 4}`);
// i used modulo operator to obtain
//the remainder when 21 is divided by 4
9 changes: 9 additions & 0 deletions Week1/homework/js-exercises/logString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'
var myString = "Aklilu Mezene Tsigie";
console.log("My Full Name is:");
console.log(myString);
myString = "A String is a text inside a double or single quote";
console.log("What is a String?") ;
console.log(myString);


7 changes: 7 additions & 0 deletions Week1/homework/js-exercises/roundNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'
var z = 7.25;
console.log(z);
var a = Math.round(z);
console.log(a);
var y = Math.max(z,a);
console.log(y);
50 changes: 50 additions & 0 deletions Week1/homework/js-exercises/typeChecker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict'
let capitalCity1="Tokyo";
let capitalCity2="Mexico City";
var person = {firstName:'John' , lastName:'Doe' , age:'50' , eyeColor:'blue'};
var airPort = {city:'Athens', runWayLength:'4Km', elevation:'94m'};

//logging two different data type out of the six variables declared

console.log(typeof (capitalCity2));
console.log(typeof (person));

//comparing data types of Each Variables

if(typeof (capitalCity1) == typeof (person)){
console.log('The data type of variable +" "+ "capitalCity1" is: the SAME TYPE as variable "person"');
} else {
console.log("The data type of" + 'variable "capitaCity1" is:' + "Not the same as" + 'variable "person"');
}
if(typeof (capitalCity1) == typeof (capitalCity2)){
console.log("The data type of" + 'variable "capitalCity1" is:' + "the SAME TYPE as" + 'variable "capitalCity2"');
} else {
console.log("The data type of" + 'Variable "capitalCity1" is:' + "Not the same as" + 'Variable "capitalCity2"');
}
if(typeof (capitalCity1) == typeof (airPort)){
console.log("The data type of" + 'variable "capitalCity1" is:' + "the SAME TYPE as" + 'variable "airPort"');
} else {
console.log("The data type of" + 'Variable "capitalCity1" is:' + "Not the same as" + 'variable "airPort"');
}
if(typeof (capitalCity2) == typeof (person)){
console.log("The data type of" + 'variable "capitalCity2" is:' + "the SAME TYPE as" + 'variable "person"');
} else {
console.log("The data type of" + 'variable "capitalCity2" is:' + "Not the same as" + 'variable "person"');
}
if(typeof (capitalCity2) == typeof (airPort)){
console.log("The data type of" + 'variable "capitalCity2" is:' + "the SAME TYPE as" + 'variable "airPort"');
} else {
console.log("The data type of" + 'variable "capitalCity2" is:' + "Not the same as" + 'variable "airPort"');
}

if(typeof (person) == typeof (airPort)){
console.log("The data type of" + 'variable "person" is:' + "the SAME TYPE as" + 'variable "airPort"');
} else {
console.log("The data type of" + 'variable "person" is:' + "Not the same as" + 'variable "airPort"');
}