diff --git a/eloquentjavascript/functions.js b/eloquentjavascript/functions.js index 0a7b887..ec78d69 100644 --- a/eloquentjavascript/functions.js +++ b/eloquentjavascript/functions.js @@ -1,3 +1,21 @@ -const square = function(x) { +const square = function (x) { return x * x; -} \ No newline at end of file +} + +const hummus = function (factor) { + const ingredient = function (amount, unit, name) { + let ingredientAmount = amount * factor; + if (ingredientAmount > 1) { + unit += "s"; + } + console.log(`${ingredientAmount} ${unit} ${name}`); + + }; + ingredient(1, "can", "chickpeas"); + ingredient(0.25, "cup", "tahini"); + ingredient(0.25, "cup", "lemon juice"); + ingredient(1, "clove", "garlic"); + ingredient(2, "tablespoon", "olive oil"); + ingredient(0.5, "teaspoon", "cumin"); +}; +hummus(10); \ No newline at end of file diff --git a/eloquentjavascript/loopingatriangle.html b/eloquentjavascript/loopingatriangle.html index 0a6db78..a239753 100644 --- a/eloquentjavascript/loopingatriangle.html +++ b/eloquentjavascript/loopingatriangle.html @@ -13,9 +13,6 @@ function start(){ triangle += "#" document.getElementById('triangle').innerHTML += `` - if (document.getElementById('triangle').innerHTML.length() == 5) { - console.log('Nice'); - } } diff --git a/intro_html/index.html b/intro_html/index.html index d02276d..d0e94e7 100644 --- a/intro_html/index.html +++ b/intro_html/index.html @@ -69,11 +69,7 @@
- +
diff --git a/intro_js/variablerN4m1_2.html b/intro_js/variablerN4m1_2.html index 4154ae4..f3955a7 100644 --- a/intro_js/variablerN4m1_2.html +++ b/intro_js/variablerN4m1_2.html @@ -17,6 +17,7 @@ console.log(yo, yo2); } console.log(yo); + console.log(yo2); } testScopes(); diff --git a/intro_js/bakgrunnsfarge.html b/oppgaver/uke3/bakgrunnsfarge.html similarity index 77% rename from intro_js/bakgrunnsfarge.html rename to oppgaver/uke3/bakgrunnsfarge.html index 447c9c6..e046b18 100644 --- a/intro_js/bakgrunnsfarge.html +++ b/oppgaver/uke3/bakgrunnsfarge.html @@ -36,8 +36,8 @@
-

Class List

- +

Class

+

Klikk på farge for å velge, klikk på boks eller knapp for å sette fargen

farge1
farge2
farge3
@@ -54,35 +54,27 @@ console.log(farge1, farge2, farge3); function getColor1() { farge = document.getElementById('farge1').className; + console.log(farge); } function getColor2() { farge = document.getElementById('farge2').className; - console.log(farge) + console.log(farge); } function getcolor3() { farge = document.getElementById('farge3').className; - console.log(farge) + console.log(farge); } function setColor1() { document.getElementById('box-1').classList.add(farge); - console.log(farge) + console.log(farge); } function setColor2() { document.getElementById('box-2').classList.add(farge); - console.log(farge) + console.log(farge); } function changeBgColor() { document.getElementById('page').classList.add(farge); } - - // paragraph.classList.add('bold', 'red-bg', 'big-font'); - // paragraph.classList.remove('bold'); - // paragraph.classList.replace('big-font', 'white-text'); - - // paragraph.classList.toggle('red-bg'); - // paragraph.classList.toggle('red-bg'); - // console.log(paragraph.classList.contains('red-bg')); - // console.log(paragraph.classList); diff --git a/intro_js/stoppeklokke.html b/oppgaver/uke3/stoppeklokke.html similarity index 100% rename from intro_js/stoppeklokke.html rename to oppgaver/uke3/stoppeklokke.html