Skip to content

Commit cbd9844

Browse files
committed
Add lambda function example
1 parent bfa6467 commit cbd9844

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: JavaScript/1-simple.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
function inc(a) {
4-
return ++a;
4+
return a + 1;
55
}
66

77
const sum = function(a, b) {
@@ -10,6 +10,12 @@ const sum = function(a, b) {
1010

1111
const max = (a, b) => (a > b ? a : b);
1212

13+
const avg = (a, b) => {
14+
const s = sum(a, b);
15+
return s / 2;
16+
};
17+
1318
console.log('inc(5) = ' + inc(5));
1419
console.log('sum(1, 3) = ' + sum(1, 3));
1520
console.log('max(8, 6) = ' + max(8, 6));
21+
console.log('avg(8, 6) = ' + avg(8, 6));

0 commit comments

Comments
 (0)