someIsNegative

Easy · Functional Programming Concepts · 3 test cases

Given an array of numbers, use the `some` method to check if at least one number in the array is negative.

Examples

someIsNegative([1, -2, 3]) → true
someIsNegative([1, 2, 3]) → false

Starter code

function someIsNegative(arr) {

}

Complexity of the optimal solution

Time O(n), space O(1). The `some` method iterates through the array but stops as soon as it finds an element that satisfies the condition. In the worst case (no negative numbers), it checks all 'n' elements. Space is constant.

Solve someIsNegative in the browser