I want to write a function that returns true if there exists at least one number that is larger than or equal to n.
Below is my code. I am trying to use array methods and ternary operators.
function existsHigher(arr, n) {
let newArr = [];
arr.forEach(e => {
if (n>e) {
newArr.push(n)
}
})
console.log(newArr)
(newArr.length !== 0) ? true:false
}
existsHigher([5, 3, 15, 22, 4], 10) //➞ should return true
My code is returning:
What am I doing wrong?