Skip to content

Commit 227dda9

Browse files
committed
javascript fixes
1 parent 7cf7938 commit 227dda9

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/javascript/tutorial.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ descr: >
1414
- [node.js](https://nodejs.org/en/)
1515
code:
1616
- |
17-
# a simple calculation
17+
// a simple calculation
1818
1+1
1919
- |
20-
# the version of Node.js
20+
// the version of Node.js
2121
process.version
2222
---
2323
title: Variables
@@ -26,11 +26,11 @@ descr: >
2626
`let` tells JavaScript, that this is a new variable.
2727
code:
2828
- |
29-
# define x
29+
// define x
3030
let x = 20
3131
x
3232
- |
33-
# now refer to x in a calculation
33+
// now refer to x in a calculation
3434
2 * x + 1
3535
---
3636
title: Print output
@@ -81,12 +81,25 @@ descr: >
8181
code:
8282
- |
8383
function f1(x) {
84-
return 2*x+1;
84+
return 2 * x + 1;
8585
}
8686
- |
8787
function bar(func, arg) {
88-
let y = 2 * func(arg) * 1
88+
let y = 1 + func(arg) + func(arg + 1)
8989
return y;
9090
}
9191
- |
9292
bar(f1, 3)
93+
---
94+
category: Tutorial / Iterations
95+
---
96+
title: for-loop
97+
descr: >
98+
A for-loop iterates a value over a block of code.
99+
code:
100+
- |
101+
let sum = 0;
102+
for (let i = 0; i < 10; i++) {
103+
sum += i;
104+
}
105+
sum;

0 commit comments

Comments
 (0)