From 374171dd9587b641a4fe971c2d45713467621245 Mon Sep 17 00:00:00 2001 From: Mucahit Date: Fri, 6 Mar 2020 12:07:18 +0100 Subject: [PATCH] js exercises and index.html, style.css for the project finished --- .DS_Store | Bin 6148 -> 8196 bytes Week3/homework/js-exercises/ex1-AddSix.js | 16 +++++++ .../js-exercises/ex2-RemoveDuplicates.js | 7 +++ .../js-exercises/ex3-GuessTheOutput.js | 13 ++++++ Week3/homework/js-exercises/ex4-GuessMore.js | 20 +++++++++ .../js-exercises/ex5-LotteryMachine.js | 38 ++++++++++++++++ Week3/homework/project/app.js | 1 + Week3/homework/project/index.html | 41 ++++++++++++++++++ Week3/homework/project/style.css | 23 ++++++++++ 9 files changed, 159 insertions(+) create mode 100644 Week3/homework/js-exercises/ex1-AddSix.js create mode 100644 Week3/homework/js-exercises/ex2-RemoveDuplicates.js create mode 100644 Week3/homework/js-exercises/ex3-GuessTheOutput.js create mode 100644 Week3/homework/js-exercises/ex4-GuessMore.js create mode 100644 Week3/homework/js-exercises/ex5-LotteryMachine.js create mode 100644 Week3/homework/project/app.js create mode 100644 Week3/homework/project/index.html create mode 100644 Week3/homework/project/style.css diff --git a/.DS_Store b/.DS_Store index 19f35c2d407a08177dbf67c9e46b596ee6108156..abe5d4347fc1a91580949d65add86d88b73b89f6 100644 GIT binary patch literal 8196 zcmeHLU2GIp6h5c4Ff*leia&@FBG+s^Kcbi#C|?96U~ zQd2SNivjhG@?c_6QA~W|#TNtt#wwt`8ZKwzl z2oVSo2oVSo2od;iAV6m}OVT~gePIpr5P=YZ|0M$K`w*pv$ygvKh2)uyO%&enDjfA7r%d+9JMXaZ*2Sui{=!U%$+Amilme&hkJ+Jv0h*I zGhUmXKFDf&b$>V+l;f^z&y@A#e#;z7sEgWN$JZ^#Omk<;FsaF*e#2BRO1v-BNBC}DJs$)ZwG;siqQYE28z%;iu6@nybt9R}@k~wpB>cYi0 z-hAuYb?yW+I8})HO#UI2W}#tw*>-W2Q}pWH(9m{u?N$=%!Yu7@&!}&?j1q+j+wQi+q_b zp{g0r+-H)5l{Gua%~MgnJb!Uy)uU?~H*9&leY$KxxmvMMQ4SD!9N&7{GShuyY%>OR zFJ(H0dbi zK{I&LHP|SIdPS1CrFx~N9b}gFv`M)kNz>|r@-n4XtCLk-ihHyWp;@b}lT}ZSA0y^- zjn=HJmsCUUv-PBD3stMKSyK1N{aJygP%c!qN%BC-9T}lTdVJXJF-<$dhV9lpzh~5R zXiA^Z*kzSfOFC#ugUq(WFxZ5MG__)*IR@3SMp2XL*wvtc4%uCBh&}v#ii;w>?~ zqTD;(E$X=(Z&N9stHHHn(cs;<8tLfV`7d$x)_g(GM;0w!QC+*Xxpix7W*ZB3Z#IWG zX#^`cTXJmR+m}Z}MrCd3G9}VSq%uzw5;;e3bsi(WG_4UkBGJeyiMXN$)tbm^iP)?b z@xC6bizw2j^PP>7SG^wM8dOpj!5_lPT^~Ksep33a%2+{-_EC8 z!7-BG_~EF{5!0+<@qg#N@Bbf;#e}mA5eN~uF9fi-qqn1tTyv*wVJ|G!j?yzk4@<1w zq>$W&GS-CYc{olo2* [...new Set(arr)]; + +console.log(removeDuplicates(letters)); \ No newline at end of file diff --git a/Week3/homework/js-exercises/ex3-GuessTheOutput.js b/Week3/homework/js-exercises/ex3-GuessTheOutput.js new file mode 100644 index 000000000..5f7237f74 --- /dev/null +++ b/Week3/homework/js-exercises/ex3-GuessTheOutput.js @@ -0,0 +1,13 @@ +'use strict'; + +//the output would be 12. The returning function will be returned as closure. So it will use the 'variable a' from its outer function which has been assigned a new value(12). + +let a = 10; +const x = (function () { + a = 12; + return function () { + alert(a); + }; +})(); + +x(); \ No newline at end of file diff --git a/Week3/homework/js-exercises/ex4-GuessMore.js b/Week3/homework/js-exercises/ex4-GuessMore.js new file mode 100644 index 000000000..b2207df4c --- /dev/null +++ b/Week3/homework/js-exercises/ex4-GuessMore.js @@ -0,0 +1,20 @@ +'use strict'; +const x = 9; + +function f1(val) { + val = val + 1; + return val; +} +f1(x); +console.log(x); //prints 9, because x is assigned a new value in the function(local) not in global scope + +const y = { + x: 9 +}; + +function f2(val) { + val.x = val.x + 1; + return val; +} +f2(y); +console.log(y); //prints {x:10}, due to its an object; the changes on variable y will affect the y in global scope \ No newline at end of file diff --git a/Week3/homework/js-exercises/ex5-LotteryMachine.js b/Week3/homework/js-exercises/ex5-LotteryMachine.js new file mode 100644 index 000000000..eda513141 --- /dev/null +++ b/Week3/homework/js-exercises/ex5-LotteryMachine.js @@ -0,0 +1,38 @@ +'use strict'; + +function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) { + const numbers = []; + for (let indis = startIndex; indis <= stopIndex; indis++) { + numbers.push(indis); + } + console.log(numbers); + numbers.forEach(function (indis) { + if (indis % 15 === 0) { + // console.log('five and three'); + // console.log(indis); + threeCallback(); + fiveCallback(); + } else if (indis % 5 === 0) { + // console.log(indis); + // console.log('only five'); + fiveCallback(); + + } else if (indis % 3 === 0) { + // console.log(indis); + // console.log('only three') + threeCallback(); + } + }); + +} +const sayThree = function () { + console.log('sayThree callback called'); +} + +const sayFive = function () { + console.log('sayFive callback called'); +} +threeFive(10, 15, sayThree, sayFive); + +// Should create an array [10,11,12,13,14,15] +// and call sayFive, sayThree, sayThree, sayFive \ No newline at end of file diff --git a/Week3/homework/project/app.js b/Week3/homework/project/app.js new file mode 100644 index 000000000..a726efc43 --- /dev/null +++ b/Week3/homework/project/app.js @@ -0,0 +1 @@ +'use strict'; \ No newline at end of file diff --git a/Week3/homework/project/index.html b/Week3/homework/project/index.html new file mode 100644 index 000000000..67ddea3a6 --- /dev/null +++ b/Week3/homework/project/index.html @@ -0,0 +1,41 @@ + + + + + + + Document + + + + +
+

TIP CALCULATOR

+
+
+
+
+
+
+
+ +
+

TIP AMOUNT

+

+

each

+
+ + + + + + + + \ No newline at end of file diff --git a/Week3/homework/project/style.css b/Week3/homework/project/style.css new file mode 100644 index 000000000..9fb91198c --- /dev/null +++ b/Week3/homework/project/style.css @@ -0,0 +1,23 @@ +* { + margin: 0; + padding: 0; +} + +body { + background-color: #68150B; + display: flex; + align-items: center; + justify-content: center; + height: 100%; +} + +.main-container { + text-align: left; + padding: 3%; + width: 30%; + height: 70%; + margin: auto; + background-color: white; + font-size: 1.3em; + border-radius: 25px; +} \ No newline at end of file