diff --git a/Week2/.DS_Store b/Week2/.DS_Store new file mode 100644 index 000000000..57a99912f Binary files /dev/null and b/Week2/.DS_Store differ diff --git a/Week3/.DS_Store b/Week3/.DS_Store new file mode 100644 index 000000000..57a99912f Binary files /dev/null and b/Week3/.DS_Store differ diff --git a/Week3/js-exercises/.DS_Store b/Week3/js-exercises/.DS_Store new file mode 100644 index 000000000..5008ddfcf Binary files /dev/null and b/Week3/js-exercises/.DS_Store differ diff --git a/Week3/js-exercises/addSix.js b/Week3/js-exercises/addSix.js new file mode 100644 index 000000000..194a90abc --- /dev/null +++ b/Week3/js-exercises/addSix.js @@ -0,0 +1,11 @@ +'use strict'; +function createBase(baseNumber) { + return function(N) { + return baseNumber + N; + }; +} + +const addSix = createBase(6); +addSix(9); +addSix(18); +addSix(30); diff --git a/Week3/js-exercises/ex3.js b/Week3/js-exercises/ex3.js new file mode 100644 index 000000000..1d678aa9d --- /dev/null +++ b/Week3/js-exercises/ex3.js @@ -0,0 +1,14 @@ +// Snippet +let a = 10; // global variable declared by let +const x = (function() { + a = 12; // global variable modified + return function() { + // returns outer schope` value + + alert(a); // alerts window the output of inner function + }; +})(); // IIFE it can directly execute the function. + +x(); //the out put is 12, coz it declared by let . +// Functions are objects in JS,and can be asinged with variable, +// and this function expressions calls the function value diff --git a/Week3/js-exercises/ex4.js b/Week3/js-exercises/ex4.js new file mode 100644 index 000000000..d2a0c7709 --- /dev/null +++ b/Week3/js-exercises/ex4.js @@ -0,0 +1,20 @@ +// Snippet +const x = 9; // The const global variable +function f1(val) { + val = val + 1; // this function increases the value of argument val by 1 each time when it is called + return val; +} +f1(x); // it is 10, f1 function call with argument x, but not change value of variable x + +const y = { x: 9 }; // +function f2(val) { + val.x = val.x + 1; + return val; +} +f2(y); // output is { x: 10 }, coz f2 modifies the value of object property +console.log(y); //output is { x: 10 },coz f2 modifies the value of object property + +// The const declaration creates a read-only reference to a value. +// It does not mean the value it holds is immutable, just that the variable identifier cannot be reassigned. +// For instance, in the case where the content is an object, this means the object's +// contents (e.g., its properties) can be altered. diff --git a/Week3/js-exercises/lotteryMachine.js b/Week3/js-exercises/lotteryMachine.js new file mode 100644 index 000000000..761603af1 --- /dev/null +++ b/Week3/js-exercises/lotteryMachine.js @@ -0,0 +1,22 @@ +'use strict'; +const sayThree = n => console.log(n, 'sayThree'); +const sayFive = n => console.log(n, 'sayFive,'); + +function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) { + const numbers = []; + for (i = startIndex; i <= stopIndex; i++) { + numbers.push(i); + console.log(numbers); + } + numbers.forEach(e => { + if (e % 15 === 0) { + sayThree(e); + sayFive(e); + } else if (e % 3 === 0) { + sayThree(e); + } else if (e % 5 === 0) { + sayFive(e); + } + }); +} +threeFive(10, 15, sayThree, sayFive); diff --git a/Week3/js-exercises/project/.DS_Store b/Week3/js-exercises/project/.DS_Store new file mode 100644 index 000000000..5008ddfcf Binary files /dev/null and b/Week3/js-exercises/project/.DS_Store differ diff --git a/Week3/js-exercises/project/tips.css b/Week3/js-exercises/project/tips.css new file mode 100644 index 000000000..bd4dc1099 --- /dev/null +++ b/Week3/js-exercises/project/tips.css @@ -0,0 +1,101 @@ +* { + margin: 0; + padding: 0; + outline: none; +} + +body{ + font-family:Robotto; + background: linear-gradient(to left, #AD133A, #1F050B); + color: black; +} + +#container{ + height: 550px; + width: 360px; + margin: 100px auto; + background:white; + box-shadow: 0 0 3px #1F050B; + border-radius: 20px; +} + +h1{ +background: #1F050B; +color: white; +padding: 10px 100px; +font-size: 18px; +border-radius: 20px 20px 0 0; +} + +form label { + display: block; + margin: 25px 15px; + font-weight: bold; +} + + +form input, +form select { + padding-left: 20px; + margin: 10px 0; +} + +form input[type='text'] { + width: 90px; +} + +#bill{ + font-size: 15px; + background-color: white; + width: 60%; + padding: 5px 5px 8px 8px; +} + +#totalpeople{ + font-size: 15px; + background-color: white; + width: 60%; + padding: 5px 5px 8px 8px; + margin-left: 20px; +} + +#service { + margin-left: 20px; + font-size: 25px; + padding: 13px 13px 20px 20px; +} + +button { + font-size: 17px; + font-weight: bold; + display: block; + margin: 20px auto; + background:#AD133A; + color: white; + border-radius: 5px; + width: 200px; + height: 50px; +} + + +button:hover { + background: #1F050B; +} + + +#totaltip { + font-size: 25px; + margin-top: 5px; + text-align: center; +} + +#totaltip small { + font-size: 20px; + font-weight: bold; + display: block; +} + + + + + diff --git a/Week3/js-exercises/project/tips.html b/Week3/js-exercises/project/tips.html new file mode 100644 index 000000000..8f51e133e --- /dev/null +++ b/Week3/js-exercises/project/tips.html @@ -0,0 +1,50 @@ + + +
+ + + + +