diff --git a/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/source.js b/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/source.js index 5bf29aa2d..0d0c9ba68 100644 --- a/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/source.js +++ b/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/source.js @@ -1,18 +1,18 @@ function makeCounter() { let count = 0; - // ... your code ... + // ... din kode ... } let counter = makeCounter(); -alert( counter() ); // 0 -alert( counter() ); // 1 +alert(counter()); // 0 +alert(counter()); // 1 -counter.set(10); // set the new count +counter.set(10); // sæt en ny værdi -alert( counter() ); // 10 +alert(counter()); // 10 -counter.decrease(); // decrease the count by 1 +counter.decrease(); // formindsk tælleren med 1 -alert( counter() ); // 10 (instead of 11) +alert(counter()); // 10 (i stedet for 11) diff --git a/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/test.js b/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/test.js index 0e613aba7..adb836200 100644 --- a/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/test.js +++ b/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/test.js @@ -1,39 +1,39 @@ -describe("counter", function() { +describe("counter", function () { - it("increases from call to call", function() { + it("forøger tælleren fra kald til kald", function () { let counter = makeCounter(); - assert.equal( counter(), 0 ); - assert.equal( counter(), 1 ); - assert.equal( counter(), 2 ); + assert.equal(counter(), 0); + assert.equal(counter(), 1); + assert.equal(counter(), 2); }); - - describe("counter.set", function() { - it("sets the count", function() { + + describe("counter.set", function () { + it("sætter tælleren", function () { let counter = makeCounter(); counter.set(10); - assert.equal( counter(), 10 ); - assert.equal( counter(), 11 ); + assert.equal(counter(), 10); + assert.equal(counter(), 11); }); }); - - describe("counter.decrease", function() { - it("decreases the count", function() { + + describe("counter.decrease", function () { + it("formindsker tælleren", function () { let counter = makeCounter(); counter.set(10); - assert.equal( counter(), 10 ); + assert.equal(counter(), 10); counter.decrease(); - assert.equal( counter(), 10 ); + assert.equal(counter(), 10); }); }); diff --git a/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/solution.md b/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/solution.md index e829d96ee..ed5c2b968 100644 --- a/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/solution.md +++ b/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/solution.md @@ -1,2 +1,2 @@ -The solution uses `count` in the local variable, but addition methods are written right into the `counter`. They share the same outer lexical environment and also can access the current `count`. +Løsningen bruger `count` i den lokale variabel, men tilføjede metoder er skrevet direkte ind i `counter`. De deler det samme ydre leksikale miljø og kan også tilgå den nuværende `count`. diff --git a/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/task.md b/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/task.md index a11821d67..de12cdfeb 100644 --- a/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/task.md +++ b/1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/task.md @@ -2,14 +2,14 @@ importance: 5 --- -# Set and decrease for counter +# Sæt og formindsk for counter -Modify the code of `makeCounter()` so that the counter can also decrease and set the number: +Juster på koden `makeCounter()` så tælleren også kan formindske tallet og sætte den til et bestemt tal: -- `counter()` should return the next number (as before). -- `counter.set(value)` should set the counter to `value`. -- `counter.decrease()` should decrease the counter by 1. +- `counter()` skal returnere det næste tal (as before). +- `counter.set(value)` skal sætte tælleren til `value`. +- `counter.decrease()` skal formindske tælleren med 1. -See the sandbox code for the complete usage example. +Se sandbox-koden for det fulde brugseksempel. -P.S. You can use either a closure or the function property to keep the current count. Or write both variants. +P.S. Du kan bruge enten en closure eller funktionsegenskab til at gemme den nuværende tæller. Eller skriv begge varianter.