Skip to content

Commit 7cb5896

Browse files
committed
function-conversion completed
1 parent 3e17be3 commit 7cb5896

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎assignments/function-conversion.js‎

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

33
// let myFunction = function () {};
4+
let myFunction = () => {};
45

56
// let anotherFunction = function (param) {
67
// return param;
78
// };
89

10+
let anotherFunction = param => param;
11+
console.log(anotherFunction(2));
12+
913
// let add = function (param1, param2) {
1014
// return param1 + param2;
1115
// };
1216
// add(1,2);
17+
let add = (param1, param2) => param1 + param2;
18+
19+
console.log(add(1,2));
20+
21+
// let subtract = function (param1, param2) {
22+
// return param1 - param2;
23+
// };
24+
// subtract(1,2); //?
1325

14-
let subtract = function (param1, param2) {
15-
return param1 - param2;
16-
};
17-
subtract(1,2); //?
26+
let subtract = (param1, param2) => param1-param2;
27+
console.log(subtract(1,2)); //?
1828

19-
exampleArray = [1,2,3,4];
29+
let exampleArray = [1,2,3,4];
2030
// const triple = exampleArray.map(function (num) {
2131
// return num * 3;
2232
// });
23-
// console.log(triple);
33+
// console.log(triple);
34+
const triple = exampleArray.map(num => num *3 );
35+
console.log(triple);

0 commit comments

Comments
 (0)