Skip to content

Commit 620cd6b

Browse files
author
Gill Abada
committed
Complete stretch function conversion and convert all call backs to arrow syntax.
1 parent c8c7c67 commit 620cd6b

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

assignments/callbacks.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];
2727
return cb(arr.length);
2828
}
2929

30-
getLength(items, function(long) {
30+
getLength(items, (long) => {
3131
console.log(long);
3232
});
3333

3434
function last(arr, cb) {
3535
// last passes the last item of the array into the callback.
3636
return cb(arr[arr.length-1])
3737
}
38-
last(items, function(length) {
38+
last(items, (length) => {
3939
console.log(length);
4040
});
4141

@@ -44,7 +44,7 @@ function sumNums(x, y, cb) {
4444
return cb(x+y);
4545
}
4646

47-
sumNums(505, 505, function(result) {
47+
sumNums(505, 505, (result) => {
4848
console.log(result);
4949
});
5050

@@ -53,7 +53,7 @@ function multiplyNums(x, y, cb) {
5353
return cb(x*y);
5454
}
5555

56-
multiplyNums(3, 10, function(result){
56+
multiplyNums(3, 10, (result) =>{
5757
console.log(result);
5858
});
5959

@@ -63,7 +63,7 @@ function contains(item, list, cb) {
6363
return cb(list.includes(item));
6464
}
6565

66-
contains("Gum", items, function(doesIt){
66+
contains("Gum", items, (doesIt) => {
6767
console.log(doesIt);
6868
})
6969

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
// Take the commented ES5 syntax and convert it to ES6 arrow Syntax
22

3-
// let myFunction = function () {};
3+
let myFunction = () => {};
44

5-
// let anotherFunction = function (param) {
6-
// return param;
7-
// };
5+
let anotherFunction = (param) => {
6+
return param;
7+
};
88

9-
// let add = function (param1, param2) {
10-
// return param1 + param2;
11-
// };
12-
// add(1,2);
9+
let add = (param1,param2) => {
10+
return param1 + param2;
11+
};
1312

14-
// let subtract = function (param1, param2) {
15-
// return param1 - param2;
16-
// };
17-
// subtract(1,2);
13+
add(1,2);
1814

19-
// exampleArray = [1,2,3,4];
20-
// const triple = exampleArray.map(function (num) {
21-
// return num * 3;
22-
// });
23-
// console.log(triple);
15+
let subtract = (param1, param2) => {
16+
return param1 - param2;
17+
};
18+
subtract(1,2);
19+
20+
exampleArray = [1,2,3,4];
21+
const triple = exampleArray.map( (num) => {
22+
return num * 3;
23+
});
24+
console.log(triple);

0 commit comments

Comments
 (0)