diff --git a/wk3/ex1/addSix.js b/wk3/ex1/addSix.js new file mode 100644 index 000000000..e1eb2609d --- /dev/null +++ b/wk3/ex1/addSix.js @@ -0,0 +1,18 @@ +"use strict"; + +function createBase(base) { + function add(num) { + return base + num; + } + return add; +} + +const addSix = createBase(6); + +// Put here your function calls... with newNumber + +console.log(addSix(9)); // 15 + +console.log(addSix(18)); //24 + +console.log(addSix(30)); //36 \ No newline at end of file diff --git a/wk3/ex2/TakeOutTheDuplicates.js b/wk3/ex2/TakeOutTheDuplicates.js new file mode 100644 index 000000000..0e63e93ba --- /dev/null +++ b/wk3/ex2/TakeOutTheDuplicates.js @@ -0,0 +1,4 @@ +const letters = ["a", "b", "c", "d", "a", "e", "f", "c", "b"]; + +let newLetters = letters => letters.filter((v, i) => letters.indexOf(v) === i); +console.log(newLetters(letters)); \ No newline at end of file diff --git a/wk3/ex3/GuessTheOutput.js b/wk3/ex3/GuessTheOutput.js new file mode 100644 index 000000000..92a7589c4 --- /dev/null +++ b/wk3/ex3/GuessTheOutput.js @@ -0,0 +1,17 @@ +// Snippet + +let a = 10; +// the verbal a take 10 as value + +const x = (function() { + // here we give new value to the same variable that variable. + a = 12; + // then the value of variable x will be 12 + + return function() { + alert(a); + }; +})(); + +// the output for function x it will be 12 +x(); \ No newline at end of file diff --git a/wk3/ex4/GuessMore.js b/wk3/ex4/GuessMore.js new file mode 100644 index 000000000..88ddc75ba --- /dev/null +++ b/wk3/ex4/GuessMore.js @@ -0,0 +1,27 @@ +// Snippet +const x = 9; + +function f1(val) { + val = val + 1; + return val; +} +// when the functions f() fired it will increase verbal x +// so the output the value will be 10 +f1(x); + +// the function will not change the variable x value it will be still the sam so the output is 9 +console.log(x); + +const y = { x: 9 }; + +function f2(val) { + val.x = val.x + 1; + return val; +} + +// when the functions f2() fired it will increase the object y +// so the output the value will be 10 +f2(y); + +// the function here will change the the value of the object the output is 10 +console.log(y); \ No newline at end of file diff --git a/wk3/ex5/lotteryMachine.js b/wk3/ex5/lotteryMachine.js new file mode 100644 index 000000000..a2b9dc7be --- /dev/null +++ b/wk3/ex5/lotteryMachine.js @@ -0,0 +1,21 @@ +// +function threeFive(startIndex, stopIndex, threeCallback = 3, fiveCallback = 5) { + const numbers = []; + const sayWhat = []; + + for (let i = startIndex; i <= stopIndex; i++) { + numbers.push(i); + } + + for (let i = 0; i < numbers.length; i++) { + if (i % threeCallback === 0) { + sayWhat.push("Three"); + } else if (i % fiveCallback === 0) { + sayWhat.push("Five"); + } + } + + return numbers + "\n" + sayWhat; +} + +console.log(threeFive(10, 15, 3, 5)); \ No newline at end of file diff --git a/wk3/project/TipCalculator.html b/wk3/project/TipCalculator.html new file mode 100644 index 000000000..772ee7141 --- /dev/null +++ b/wk3/project/TipCalculator.html @@ -0,0 +1,49 @@ + + + +
+ + + +TIP AMOUNT
+$
+EACH
+