Skip to content

Commit bf21a0c

Browse files
authored
Merge pull request #251 from ockley/master
Translated assignments to function objects
2 parents ce17683 + 1446518 commit bf21a0c

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
function makeCounter() {
22
let count = 0;
33

4-
// ... your code ...
4+
// ... din kode ...
55
}
66

77
let counter = makeCounter();
88

9-
alert( counter() ); // 0
10-
alert( counter() ); // 1
9+
alert(counter()); // 0
10+
alert(counter()); // 1
1111

12-
counter.set(10); // set the new count
12+
counter.set(10); // sæt en ny værdi
1313

14-
alert( counter() ); // 10
14+
alert(counter()); // 10
1515

16-
counter.decrease(); // decrease the count by 1
16+
counter.decrease(); // formindsk tælleren med 1
1717

18-
alert( counter() ); // 10 (instead of 11)
18+
alert(counter()); // 10 (i stedet for 11)

1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/_js.view/test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
describe("counter", function() {
1+
describe("counter", function () {
22

3-
it("increases from call to call", function() {
3+
it("forøger tælleren fra kald til kald", function () {
44

55
let counter = makeCounter();
66

7-
assert.equal( counter(), 0 );
8-
assert.equal( counter(), 1 );
9-
assert.equal( counter(), 2 );
7+
assert.equal(counter(), 0);
8+
assert.equal(counter(), 1);
9+
assert.equal(counter(), 2);
1010
});
1111

12-
13-
describe("counter.set", function() {
14-
it("sets the count", function() {
12+
13+
describe("counter.set", function () {
14+
it("sætter tælleren", function () {
1515

1616
let counter = makeCounter();
1717

1818
counter.set(10);
1919

20-
assert.equal( counter(), 10 );
21-
assert.equal( counter(), 11 );
20+
assert.equal(counter(), 10);
21+
assert.equal(counter(), 11);
2222
});
2323
});
24-
25-
describe("counter.decrease", function() {
26-
it("decreases the count", function() {
24+
25+
describe("counter.decrease", function () {
26+
it("formindsker tælleren", function () {
2727

2828
let counter = makeCounter();
2929

3030
counter.set(10);
3131

32-
assert.equal( counter(), 10 );
32+
assert.equal(counter(), 10);
3333

3434
counter.decrease();
3535

36-
assert.equal( counter(), 10 );
36+
assert.equal(counter(), 10);
3737

3838
});
3939
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

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`.
2+
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`.

1-js/06-advanced-functions/06-function-object/2-counter-inc-dec/task.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ importance: 5
22

33
---
44

5-
# Set and decrease for counter
5+
# Sæt og formindsk for counter
66

7-
Modify the code of `makeCounter()` so that the counter can also decrease and set the number:
7+
Juster på koden `makeCounter()` så tælleren også kan formindske tallet og sætte den til et bestemt tal:
88

9-
- `counter()` should return the next number (as before).
10-
- `counter.set(value)` should set the counter to `value`.
11-
- `counter.decrease()` should decrease the counter by 1.
9+
- `counter()` skal returnere det næste tal (as before).
10+
- `counter.set(value)` skal sætte tælleren til `value`.
11+
- `counter.decrease()` skal formindske tælleren med 1.
1212

13-
See the sandbox code for the complete usage example.
13+
Se sandbox-koden for det fulde brugseksempel.
1414

15-
P.S. You can use either a closure or the function property to keep the current count. Or write both variants.
15+
P.S. Du kan bruge enten en closure eller funktionsegenskab til at gemme den nuværende tæller. Eller skriv begge varianter.

0 commit comments

Comments
 (0)