Exercise : Multiply each element by 2 and return only those element which are greater than 10

 

// multiple each element with 2 and return only

 those element which are greater than 10


let arr = [234,5,6,7]

let newelement1 = arr.map((ele,index,array)=>
{
    return ele*2
}).filter((ele)=>{
    return ele > 10
});
console.log(newelement1);

shortening the above code :
----------------------------
let newelement1 = arr.map((ele,index,array)=>  ele*2
).filter((ele)=>ele > 10);

0 Comments