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

Skip to content

Commit 3cedfba

Browse files
authored
Merge pull request #1 from mim09/week1-ayda
Week1 ayda
2 parents 4533787 + 1d9ffa3 commit 3cedfba

File tree

10 files changed

+136
-0
lines changed

10 files changed

+136
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
// Exercise 10: Compare arrays
4+
5+
//declare and initialize an array that contain my favorite foods
6+
const myFavCities = ['Amsterdam', 'Addis Abeba', 'Paris', 'Barcelona'];
7+
const myFavFoods = [{Italian: 'spagheti'}, 'rice', {Ethiopian: 'enjera with Dorowet'}, 'salad', 'fish', 'roasted beef', 'couscus'];
8+
//length of the arrays
9+
let len = myFavCities.length;
10+
let lenFoods = myFavFoods.length;
11+
//print out the length's of the arrays
12+
console.log('The length of the firsta array is '+ len);
13+
console.log('The length of the second array is '+ lenFoods);
14+
//compare the length of the array
15+
if (len==lenFoods){
16+
console.log('They are the same!');
17+
}
18+
else{
19+
console.log('Two different sizes');
20+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
// Exercise 8: Type checker
3+
var x = 'love';
4+
var y ='patience';
5+
var z = {name: 'Lelida',
6+
age: 6
7+
} ;
8+
var g = {
9+
favoriteBook: 'Prid&Prejudice',
10+
favArtist: 'Beyonce'
11+
12+
};
13+
function checktype(a, b, c, d){
14+
if (typeof a == typeof b) {
15+
console.log('SAME TYPE ' + typeof a);
16+
}
17+
else if (typeof a == typeof c) {
18+
console.log('SAME TYPE ' + typeof a);
19+
}
20+
else if (typeof a == typeof d) {
21+
console.log('SAMETYPE ' + typeof a);
22+
}
23+
else if (typeof b == typeof c) {
24+
console.log('SAME TYPE ' + typeof c);
25+
}
26+
else if (typeof b == typeof d) {
27+
console.log('SAME TYPE ' + typeof b);
28+
}
29+
else if (typeof c == typeof d) {
30+
console.log('SAME TYPE ' + typeof c);
31+
}
32+
else{
33+
console.log('Not the same ...')
34+
}
35+
}
36+
checktype(x, y, z, g);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"use strict";
2+
3+
//exercise 2:Error debugging
4+
console.log("I'm awesome!");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
3+
//exercise3: log the number
4+
var numberX;
5+
console.log('the value of numberX is not defined');
6+
console.log(numberX);
7+
numberX = 10;
8+
console.log('Now the value of numberX is ten');
9+
console.log(numberX);
10+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
// Exercise 9: Log the remainder
4+
let x =7; //declare x and initialize it to 7
5+
x= x%3; // value x will be the remainder of x divided by 3 i.e 7%3
6+
console.log(x); //value of x will be 1
7+
8+
let y = 21; //declare y and initialize it to 21
9+
y = y % 4; // value y will be the remainder of y divided by 4 i.e 21%4
10+
console.log(y); //value of y will be 1
11+
12+
let z = 7; //declare z and initialize it to 13
13+
z = z % 3; // value z will be the remainder of z divided by 2 i.e 13%2
14+
console.log(z); //value of z will be 1
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict";
2+
3+
// Exercise 4: Log the string
4+
var myString ="Ayda Hagos";
5+
console.log('The value of myString is my full name');
6+
console.log(myString);
7+
myString = "Lelida";
8+
console.log("The value of myString changed to my daughter's name");
9+
console.log(myString);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
// Exercise 6: Log an array of animals
4+
var fruits = [];
5+
console.log('my favorite fruits');
6+
console.log(fruits);
7+
var myFavAnimals = ['dog', 'cat', 'Lion'];
8+
console.log(myFavAnimals);
9+
myFavAnimals.push("piglet");
10+
console.log(myFavAnimals);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//hello world in 10 different languages
2+
"use strict";
3+
console.log("Hallo Wereld!"); //dutch
4+
console.log("Kamusta mundo!"); //Filipino
5+
console.log("Kamusta mundo!"); //Danish
6+
console.log("Bonjour le monde!"); //French
7+
console.log("Dia duit ar domhan!"); //Irish
8+
console.log("salve mundi!"); //Latin
9+
console.log("Hello dinja!"); //Maltese
10+
console.log("Hei Verden!"); //French
11+
console.log("ሰላም ዓለም!"); //Amharic
12+
console.log("Salamu, Dunia!"); //Swahili
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
// Exercise 7: Log the length of a strin
4+
var mySentence = "Programming is so interesting"; //declare a variable mysentence and initialize it
5+
console.log(mySentence.length); //prints out the length of mySentece
6+
7+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
// Exercise 5: Round a number and log it
4+
var z = 7.25;
5+
console.log('the value of z is ' + z);
6+
var a = Math.round(z);
7+
console.log(a);
8+
if (a >z){
9+
var b = a;
10+
}
11+
else{
12+
var b=z;
13+
}
14+
console.log("the highest number is "+ b);

0 commit comments

Comments
 (0)