Given below is the code in which I tried to modify an array using arrow function but while running, it returns a value of undefined as the output can someone give suggestions please
var modifyArray = (nums) => { return nums.forEach(function (element) { (element % 2 == 0) ? element *= 2 : element *= 3; }) } console.log(modifyArray([1,2,3,4,5]));
forEachmethod doesn't return any particular value, that is it will returnundefined. You can try to useArray.prototype.mapinstead. ``` return nums.map(function (element) { (element % 2 == 0) ? element *= 2 : element *= 3; }) ```