diff --git a/FunctionalFun/IMG/1.jpg b/FunctionalFun/IMG/1.jpg new file mode 100644 index 0000000..7a9f13a Binary files /dev/null and b/FunctionalFun/IMG/1.jpg differ diff --git a/FunctionalFun/IMG/2.jpg b/FunctionalFun/IMG/2.jpg new file mode 100644 index 0000000..f87d8da Binary files /dev/null and b/FunctionalFun/IMG/2.jpg differ diff --git a/FunctionalFun/IMG/3.jpg b/FunctionalFun/IMG/3.jpg new file mode 100644 index 0000000..b40a5bd Binary files /dev/null and b/FunctionalFun/IMG/3.jpg differ diff --git a/FunctionalFun/IMG/4.jpg b/FunctionalFun/IMG/4.jpg new file mode 100644 index 0000000..29df363 Binary files /dev/null and b/FunctionalFun/IMG/4.jpg differ diff --git a/FunctionalFun/IMG/5.jpg b/FunctionalFun/IMG/5.jpg new file mode 100644 index 0000000..0ff1043 Binary files /dev/null and b/FunctionalFun/IMG/5.jpg differ diff --git a/FunctionalFun/IMG/6.jpg b/FunctionalFun/IMG/6.jpg new file mode 100644 index 0000000..8cd811a Binary files /dev/null and b/FunctionalFun/IMG/6.jpg differ diff --git a/FunctionalFun/index.html b/FunctionalFun/index.html index e69de29..3f6ea60 100644 --- a/FunctionalFun/index.html +++ b/FunctionalFun/index.html @@ -0,0 +1,42 @@ + + + + + + Document + + + + +

+ +
+

Roll the dice!

+ + + +
+
+ + + + \ No newline at end of file diff --git a/FunctionalFun/script.js b/FunctionalFun/script.js index e69de29..ac52c10 100644 --- a/FunctionalFun/script.js +++ b/FunctionalFun/script.js @@ -0,0 +1,47 @@ +document.addEventListener("DOMContentLoaded", function(){ + let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 34, 10, 4, 656, 234, 31, 1, 2, 3, 43, 1, 10,23, 42, 12]; + + document.getElementById("theArray").textContent = "The array we are working on: " + numbers; + let out = document.getElementById("outputter"); + out.innerHTML += "Maximum of the array: " + Math.max(...numbers) + "
"; //The spread operator!!!!! With ... you can "unpack" a list and call the function with the parameters of single elements, not with the list + out.innerHTML += "Minimum of the array: " + Math.min(...numbers) + "

"; + + let text = "This is a complex text with words!"; + let textarray = [...text]; + out.innerHTML += "The text I'll use for an array: " + text + "
"; + out.innerHTML += "The text array: " + textarray + "
"; + out.innerHTML += "The text with dashes " + textarray.join("-") + "

"; + + let fruits = ["Apple", "Preal", "Plum", "Banana", "Orange"]; + let vegetables = ["Carrot", "pepper", "Celery", "Potatos"]; + out.innerHTML += "Fruit list: " + fruits + "
"; + out.innerHTML += "Fruit list: " + vegetables + "
"; + out.innerHTML += "Combined list: " + [...vegetables, ...fruits, "pearl"] + "

"; + + function mergedfruit(...elements) { //Get varying amount of elements and merge it with the "spread out" operator or !! rest operator !! + out.innerHTML += "Collection: " + elements + "
"; + } + mergedfruit("sth1", "sth2", "sth3"); + + function summariser(...numbers){ + let sum = 0; + for(let item in numbers){ + sum += Number(item); + } + return sum; + } + out.innerHTML += "Some Sum: " + summariser(1,2,3,4,5,6,7,8) + "
"; + + document.getElementById("dicerollerimageloader").onclick = function(){ //Imageloader + const res = document.getElementById("diceimages"); + const imagenumber = document.getElementById("numberofimages").value; + let images = []; + + for(i = 0; i < imagenumber; i++){ + let rand = Math.floor(Math.random() * 6)+1; + images.push(``); + } + + res.innerHTML = images.join(''); + } +}); \ No newline at end of file