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/homework/js-exercises/1-Hello-world.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

//Exercise 1: Hello world!

console.log('hallo,', 'wereld!'); //Nederlands
console.log('Hallo,', 'Welt!'); //german
console.log('Ciao,', 'mondo!'); // Italian
console.log('Hola,', 'mundo!'); // Spanish
console.log('Olá,', ' Mundo!'); //Portugal
console.log("Selam,", "Dünya!"); //Turkia
console.log('Halo,', 'dunia!'); // Indonesian
console.log('Bonjour,', 'le monde!'); //Bonjour le monde franca
console.log('Hai,', 'dunia!'); //Malay
console.log('Kia,', 'ora!'); //Maori
14 changes: 14 additions & 0 deletions Week1/homework/js-exercises/10-compare-arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

//Exercise 10: Compare arrays


const array1 = ['aaa', '333', false, { color: "blue" }];
const array2 = ['up', 'down', 'right', 'left', 'forward', 'behind', 'middle'];
console.log('the length of array1 is '+ array1.length);
console.log('the length of array1 is '+ array2.length);
if (array1.length == array2.length) {
console.log('They are the same!')
} else {
console.log("Two different sizes!");
}
5 changes: 5 additions & 0 deletions Week1/homework/js-exercises/2-error-debugging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

//Exercise 2: Error debugging

console.log("I'm awesome");
10 changes: 10 additions & 0 deletions Week1/homework/js-exercises/3-log-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

//Exercise 3: Log the number

let numberX; //step1
console.log("x is a variable can be any number ") //step2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I understand, but what is the value at this moment?

console.log("I will give x the value 5") //step3
numberX = 5; //step4
console.log("I think the value must be 5 now (:") //step5
console.log(numberX) //step6
21 changes: 21 additions & 0 deletions Week1/homework/js-exercises/4-log-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'

//Exercise 4: Log the string

//1-Write a console.log statement in which you explain in words what you think the value of the string is.
let myString = "Hani Badran";

//2-Write a console.log statement in which you explain in words what you think the value of the string is.
console.log("This is my name");

//3-Now "console.log" the variable 'myString'.
console.log(myString);

//4-Now reassign to the variable 'myString' a new string.
myString = "Amsterdam"

//5-Just like what you did before write a console.log statement that explains in words what you think will be logged to the console.
console.log('and this is my favorite city');

//6-Now console.log myString again.
console.log(myString);
32 changes: 32 additions & 0 deletions Week1/homework/js-exercises/5-round-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict'

//Exercise 5: Round a number and log it

//1-Declare a variable 'z' and assign the number 7.25 to it.
const z = 7.25;

//2-Write a 'console.log' statement in which you log the value of 'z'.
console.log(z);

//3-Declare another variable 'a' that has the value of 'z' but rounded to the nearest integer.
const a = 7;

//4-Write a 'console.log' statement in which you log the value of 'a'.
console.log(a);

//5-So now we have 'z' and 'a' find a way to compare the two values and store the highest of the two in a new variable.

const highest = a > z ? a : z;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice! Do you know that you can also use Math.max ?


//6-Write a console.log statement in which you log the value of the highest value.
console.log(highest);










24 changes: 24 additions & 0 deletions Week1/homework/js-exercises/6-Log-array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict'

//Exercise 6: Log an array of animals

//1-Declare variable and assign to it an empty array. Make sure that the name of the variable indicates it contains more than 1 item. For example 'items' instead of 'item'.
let colors = [];

//2-Write a 'console.log' statement that explains in words what you think the value of the array is.
console.log('this is the basic colors');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the value of the array?


//3-Write a 'console.log' statement that logs the array.
console.log('["red", "green", "blue"]');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should log the array colors


//4-Create a new variable with an array that has 3 of your favorite animals, each in a different string. Make sure the name of the variables says something about what the variable contains.
const animals = ['cats', 'dogs', 'horses'];

//5-Write a 'console.log' statement that logs the second array.
console.log(animals);

//6-Add a statement that adds another string ("Piglet") to the array of animals.
animals.push('Piglet');

//7-Write a 'console.log' statement that logs the second array!
console.log(animals);
12 changes: 12 additions & 0 deletions Week1/homework/js-exercises/7-log-length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

//Exercise 7: Log the length of a string

//1-Declare a variable called 'mySentence' and initialize it with the following string: "Programming is so interesting!".
const mySentence = 'Programming is so interesting!';

//2-Figure out (using Google) how to get the len-gth of mySentence.
const length = mySentence.length;

//3-Write a console.log statement to log the length of mySentence.
console.log(length);
42 changes: 42 additions & 0 deletions Week1/homework/js-exercises/8-type-checker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

//Exercise 8: Type checker

const str1 = 'aaa';
const str2 = 'bbb';
const obj1 = ['ccc', 'ddd'];
const obj2 = ['eee', 'fff'];
if (typeof str1 == typeof str2) {
console.log('SAME TYPE');
} else {
console.log('not the SAME...');
}

if (typeof str1 == typeof obj1) {
console.log('SAME TYPE');
} else {
console.log('not the SAME...');
}

if (typeof str1 == typeof obj2) {
console.log('SAME TYPE');
} else {
console.log('not the SAME...');
}

if (typeof str2 == typeof obj1) {
console.log('SAME TYPE');
} else {
console.log('not the SAME...');
}

if (typeof str2 == typeof obj2) {
console.log('SAME TYPE');
} else {
console.log('not the SAME...');
}
if (typeof str2 == typeof str1) {
console.log('SAME TYPE');
} else {
console.log('not the SAME...');
}
20 changes: 20 additions & 0 deletions Week1/homework/js-exercises/9-Log-remainder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

//Exercise 9: Log the remainder

//Computers use a format that cannot accurately represent a number like '0.1' or '0.3' .The '0.1' is rounded to the nearest number in that format even before the calculation happens.

//if x equals 7, and the only other statement is x = x % 3, the value of x after the calculation will be 1.
let x = 7;
x %= 3 ;
console.log(x);

//if y equals 21, and the only other statement is y = y % 4, the value of x after the calculation will be 1.
let y = 21;
y %= 4;
console.log(y);

//if z equals 13, and the only other statement is z = z % 2, the value of x after the calculation will be 1.
let z = 13;
z %= 2;
console.log(z);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

8 changes: 8 additions & 0 deletions Week2/js-exercises/ex1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//Exercise 1: Remove the comma

'use strict';

let myString = 'hello,this,is,a,difficult,to,read,sentence';
console.log(myString.length);
myString = myString.replace(/,/g," ");
console.log(myString)
15 changes: 15 additions & 0 deletions Week2/js-exercises/ex2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//Exercise 2: The even/odd reporter

'use strict';

for (let i = 0; i <= 20; i++)
{
if(i % 2 === 1)
{
console.log(`The number ${i} is odd!`)
};
if(i % 2 === 0)
{
console.log(`The number ${i} is even!`)
}
};
16 changes: 16 additions & 0 deletions Week2/js-exercises/ex3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//Exercise 3: The recipe card

'use strict';

const recipe = {
MealName: 'Papa oats',
Serves: 3,
Ingredients:[ '120 Gr Oats', '120 Gr Water', '30 Gr olive oil', '30 Gr honey', '1 tsp salt'],
};

let entries = Object.entries(recipe);

for(entries of entries){
console.log(entries)

}
Loading