You are viewing a single comment's thread. Return to all comments →
For better understanding .. every new method is a modification of previous method.. This is how it helped me understand the arrow function.
//method 1
function modifyArray(nums) { var something = function(n){ if(n%2==0) return n*2; else return n*3; } var newArray = nums.map(something); return newArray; }
// method 2
function modifyArray(nums) { var something = function(n){ var a = (n%2==0) ? n*2: n*3; return a; } var newArray = nums.map(something); return newArray; }
//method 3
function modifyArray(nums) { var something = n => n = (n%2==0) ? n*2: n*3; var newArray = nums.map(something); return newArray; }
//method 4
function modifyArray(nums) { var newArray = nums.map(n => n = (n%2==0) ? n*2: n*3); return newArray; }
//method 5
function modifyArray(nums) { return nums.map(n => n = (n%2==0) ? n*2: n*3); }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 5: Arrow Functions
You are viewing a single comment's thread. Return to all comments →
For better understanding .. every new method is a modification of previous method.. This is how it helped me understand the arrow function.
//method 1
// method 2
//method 3
//method 4
//method 5