Say you have a simple array with random numbers, given the following code, how would i reduce the line of code to use a ternary operator to render the following.
[1, 2, 1, 4, 6]
let arr = [1, 2, 3, 4, 6, 8, 9, 12, 13, 15];
let myArray = arr.map((val, i, arr) => {
if (val % 2 === 0) {
return val
} else {
return val % 2
}
});
console.log(myArray)
return val % 2, notval * 2(though it's exactly the same in all other respects)