Skip to content

Commit 02e9f76

Browse files
committed
js2w3homeworkMohammadFakhera
1 parent f24dc25 commit 02e9f76

15 files changed

Lines changed: 176 additions & 187 deletions

Week3/homework/addSix.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function createBase() {
2+
// Put here your logic...
3+
}
4+
5+
const addSix = createBase(6);
6+
7+
// Put here your function calls...
8+
addSix();

Week3/homework/guessMore.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Snippet
2+
const x = 9;
3+
function f1(val) {
4+
val = val + 1;
5+
return val;
6+
}
7+
f1(x);// the value of f1(x) is 10
8+
console.log(x);// the value of x is 9
9+
10+
const y = { x: 9 }; //y is an object
11+
function f2(val) {
12+
val.x = val.x + 1;
13+
return val; //the value of f1(x) is 10 , so the f2 will return x+1
14+
}
15+
f2(y);//the value of f2(x) 11
16+
console.log(y); //the value of y {x: 10}

Week3/homework/guessTheOutput.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Snippet
2+
let a = 10;
3+
const x = (function() {
4+
a = 12;
5+
return function() {
6+
alert(a);
7+
};
8+
})();
9+
10+
x();
11+
/*
12+
x is assigned to a function in row 3 and the function is wrapped with two parentheses and follwoed by () so
13+
the function will be declared and excuted , x() will alert 12 in browser window .
14+
*/

Week3/homework/lottery.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
arrayGenerator =function (startIndex, stopIndex,byThree,byFive) {
2+
let y= Array(stopIndex- startIndex + 1).fill().map((_, idx) => startIndex + idx)
3+
4+
5+
6+
const arrSum = arr => arr.reduce((a,b) => a + b, 0)
7+
let b = arrSum(y)
8+
byFifteen=function(){
9+
alert("the sum of the enterd array is devideble by 3&5")
10+
}
11+
byThree=function(){
12+
alert("the sum of the enterd array is devideble by 3")
13+
}
14+
byFive=function(){
15+
alert("the sum of the enterd array is devideble by 5")
16+
}
17+
18+
if(b%15===0){return byFifteen() }
19+
else if(b%5===0){return byFive()}
20+
else if(b%3===0){return byThree()}
21+
}

Week3/homework/step2-1.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

Week3/homework/step2-2.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

Week3/homework/step2-3.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

Week3/homework/step2-4.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

Week3/homework/step2-5.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

Week3/homework/step2-6.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)