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

Skip to content

Commit 49ed56e

Browse files
authored
Abdullah JS week 3
index.html and 19 js files for steps of homework
1 parent bf3fd09 commit 49ed56e

19 files changed

+265
-0
lines changed

Week3/arrays.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let favoriteAnimals = ["blowfish", "capricorn", "giraffe"];
2+
favoriteAnimals.push('turtle');
3+
console.log(favoriteAnimals);
4+
favoriteAnimals.splice(1 , 0 , 'meerkat');
5+
console.log('the value of favoriteAnimals will be: ["blowfish", "meerkat", "capricorn", "giraffe", "turtle"]');
6+
console.log(favoriteAnimals);
7+
console.log('The array has a length of: ' + favoriteAnimals.length);
8+
favoriteAnimals.splice(3 , 1 ,);
9+
console.log(favoriteAnimals);
10+
console.log('The item you are looking for is at index: '+favoriteAnimals.indexOf('meerkat'))

Week3/index.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
<style>
9+
.welcome{
10+
width: 700px;
11+
height: 500px;
12+
background-color: antiquewhite;
13+
font-family: Helvetica, sans-serif;
14+
text-align: center;
15+
}
16+
17+
</style>
18+
</head>
19+
<body>
20+
<header class="welcome"> <h1>my app</h1></header>
21+
<script src="strings.js"></script>
22+
<script src="arrays.js"></script>
23+
<script src="moreJs-1.js"></script>
24+
<script src="moreJs-2.js"></script>
25+
<script src="moreJs-3.js"></script>
26+
<script src="moreJs-4.js"></script>
27+
<script src="moreJs-5.js"></script>
28+
<script src="moreJs-6.js"></script>
29+
<script src="moreJs-7and8.js"></script>
30+
<script src="moreJs-9.js"></script>
31+
<script src="moreJs-10.js"></script>
32+
<script src="moreJs-11.js"></script>
33+
<script src="moreJs-12.js"></script>
34+
<script src="moreJs-13.js"></script>
35+
<script src="moreJs-14.js"></script>
36+
<script src="moreJs-15.js"></script>
37+
<script src="moreJs-16.js"></script>
38+
<script src="moreJs-17.js"></script>
39+
</body>
40+
</html>

Week3/moreJs-1.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function sum (a,b,c){
2+
return a+b+c ;
3+
}
4+
console.log(sum(5,6,7));

Week3/moreJs-10.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Use the list of vehicles to write an advertisement.
3+
So that it prints something like:
4+
"Amazing Joe's Garage, we service cars,
5+
motorbikes, caravans and bikes.".
6+
(Hint: use a for loop.)
7+
*/
8+
function advertisement(){
9+
// let vehicles = [' motorbike' , ' caravan', ' bike', ' car'];
10+
// variable 'vehicles' is can be read from moreJs-7and8.js
11+
// but i used it again inside of function to show you,
12+
// and in case you can run in a html seperately.
13+
let products = [];
14+
for(i=0; i<vehicles.length; i++){
15+
products.push(' ' + vehicles[i]+'s');
16+
}
17+
let lastTwoProduct = products[products.length - 2] + ' and' + products[products.length - 1] ;
18+
console.log(lastTwoProduct);
19+
products.splice((products.length - 2), 2,);
20+
21+
console.log('Amazing Abdullah\'s Garage, we sell ' + products.join() + ',' + lastTwoProduct +'.');
22+
23+
24+
}
25+
advertisement();
26+

Week3/moreJs-11.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Use the list of vehicles to write an advertisement.
3+
So that it prints something like:
4+
"Amazing Joe's Garage, we service cars,
5+
motorbikes, caravans and bikes.".
6+
(Hint: use a for loop.)
7+
8+
** below moreJs-10.js **
9+
10+
function advertisement(){
11+
let vehicles = [' motorbike' , ' caravan', ' bike', ' car'];
12+
// variable 'vehicles' is can be read from moreJs-7and8.js
13+
// but i used it again inside of function to show you,
14+
// and in case you can run in a html seperately.
15+
let products = [];
16+
for(i=0; i<vehicles.length; i++){
17+
products.push(vehicles[i]+'s');
18+
}
19+
let lastTwoProduct = products[products.length - 2] + ' and ' + products[products.length - 1] ;
20+
console.log(lastTwoProduct);
21+
products.splice(2, 2,);
22+
23+
console.log('Amazing Abdullah\'s Garage, we sell ' + products.join() + ',' + lastTwoProduct +'.');
24+
25+
26+
}
27+
*/
28+
29+
vehicles.push('turck', 'scooter');
30+
advertisement();
31+

Week3/moreJs-12.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let objCourse = {};

Week3/moreJs-13.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
objCourse = {
2+
teacher1: 'Rob',
3+
teacher2: 'Philip',
4+
teacher3: 'Unmesh',
5+
teacher4: 'Hardit',
6+
teacher5: 'Noer',
7+
teacher6: 'Sander',
8+
};
9+
console.log(objCourse);

Week3/moreJs-14.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
objCourse.langs = 'html, CSS, CLI, JavaScript';
2+
console.log(objCourse);

Week3/moreJs-15.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
let x = [1, 2, 3];
2+
let y = [1, 2, 3];
3+
let z = y;
4+
// lets see values
5+
console.log(x); // [1, 2, 3]
6+
console.log(y); // [1, 2, 3]
7+
console.log(z); // [1, 2, 3]
8+
// we sow that values of three array are same/ equal
9+
// now try equality and strict equality test
10+
console.log(x==y); //false
11+
console.log(x===y); //false
12+
console.log(x==z); //false
13+
console.log(x===z); //false
14+
console.log(y==z); //true
15+
console.log(y===z); //true
16+
// above, i sow that only y and z equals. well of course x is a different array even the value is same.
17+
// i understood that i did not tested equality of values!! :)
18+
19+
// now i want to see y and z assigns each other
20+
z.push(4);
21+
console.log(y); //[1, 2, 3, 4]
22+
23+
// we can see values of x and z equals
24+
console.log(x[0,1,2]==z[0,1,2]); //true

Week3/moreJs-16.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
let o1 = { foo: "bar" };
2+
let o2 = { foo: "bar" };
3+
let o3 = o2;
4+
o1.foo2 = 'pub';
5+
console.log(o3); //o1 doesnt change o3
6+
console.log(o1); // {foo: "bar", foo2: "pub"} o1 only changes itself
7+
8+
o3.foo2 = 'car';
9+
console.log(o2); //{foo: "bar", foo2: "car"} , o3 changes o2
10+
11+
delete o2.foo2;
12+
console.log(o3); //{foo: "bar"} , o2 changes o3
13+
14+
//we understand in the example above that
15+
// order (o3 = o2 or o2 = o3) doesnt matter.
16+

Week3/moreJs-17.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let bar = 42;
2+
typeof typeof bar;
3+
4+
console.log(typeof bar); // number the type of variable 'bar' so pure 42 is 'number'
5+
console.log(typeof typeof bar); // string / 'number' is a word. its text. its string!
6+
// because we ask for type of (type of 'bar) = ' number '

Week3/moreJs-2.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function colorCar(a){
2+
console.log('a '+ a + ' car');
3+
}
4+
//given the 'green' as a parameter..
5+
colorCar('green');

Week3/moreJs-3.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let anObject = {
2+
pieces: 3,
3+
type: 'busses?',
4+
answer:'yes',
5+
accuracy: true
6+
}
7+
8+
function printOut(a){
9+
console.log(a);
10+
}
11+
printOut(anObject);

Week3/moreJs-4.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
Create a function named vehicleType that receives a color,
3+
and a code, 1 for car, 2 for motorbike.
4+
And prints 'a blue motorbike' for example when
5+
called as vehicleType("blue", 2)
6+
*/
7+
8+
function vehicleType (color, type){
9+
let types = [' car' , ' motorbike'];
10+
console.log('a ' + color + types[(type-1)]);
11+
}
12+
vehicleType('blue' , 2);

Week3/moreJs-5.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
if (3 === 3) {
3+
console.log("yes");
4+
} else {
5+
console.log("no");
6+
}
7+
8+
in the example above, (3 === 3) is always true
9+
thats why console logs "yes" surely.
10+
if there is sth that i need to see or understand, unfortunately i did not.
11+
i am looking for feedback...
12+
*/
13+
14+
console.log("yes");

Week3/moreJs-6.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Create a function called vehicle, like before,
3+
but takes another parameter called age,
4+
so that vehicle("blue", 1, 5)
5+
prints 'a blue used car'
6+
*/
7+
8+
function vehicle (color, type, age){
9+
let types = [' car' , ' motorbike'];
10+
console.log('a ' + color +' ' + condition(age) + types[(type-1)]);
11+
}
12+
function condition(years){
13+
if (years<2){
14+
return 'new';
15+
} else {
16+
return 'used';
17+
}
18+
}
19+
vehicle('red' , 1, 3);

Week3/moreJs-7and8.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
7- Make a list of vehicles, you can add "motorbike", "caravan", "bike", or more.
3+
4+
8- How do you get the third element from that list?
5+
*/
6+
7+
8+
let vehicles = ['motorbike' , 'caravan', 'bike', 'car'];
9+
console.log (vehicles[2]); // bike

Week3/moreJs-9.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Change the function vehicle to use the list of question 7.
3+
So that vehicle("green", 3, 1) prints "a green new bike".
4+
*/
5+
6+
function vehicle (color, type, age){
7+
let vehicles = ['motorbike' , 'caravan', 'bike', 'car'];
8+
// variable 'vehicles' is can be read from moreJs-7and8.js
9+
// but i used it again inside of function to show you,
10+
// and in case you can run in a html seperately.
11+
console.log('a ' + color +' ' + condition(age) + vehicles[(type-1)]);
12+
}
13+
function condition(years){
14+
if (years<2){
15+
return 'new ';
16+
} else {
17+
return 'used ';
18+
}
19+
}
20+
vehicle('green' , 3, 1);

Week3/strings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let myString = "hello,this,is,a,difficult,to,read,sentence";
2+
console.log(myString);
3+
for (i=0; i<7; i++){
4+
myString = myString.replace(',' , ' ');
5+
}
6+
console.log(myString);

0 commit comments

Comments
 (0)