We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 5: Arrow Functions
Day 5: Arrow Functions
Sort by
recency
|
437 Discussions
|
Please Login in order to post a comment
function modifyArray(nums) { let newArr = nums.map(x => x % 2 === 0 ? x * 2 : x * 3); return newArr; }
function modifyArray(nums) { let result=[]; for(let n of nums){ if(n%2==0){ result.push(n*2) }else{ result.push(n*3) } } return result; }