Easy
Check If Any Element Matches a Condition
Description
In this challenge, you are tasked with writing a function that checks whether any element in an array meets a specified condition.
The function should take an array of numbers and a threshold value as input and return true if at least one number in the array is greater than or equal to the threshold; otherwise, return false.
The some() method is a useful tool in JavaScript that allows you to test whether at least one element in an array meets a specified condition. This is commonly used when working with validation checks, searching for specific values, or filtering data.
Example usage:
checkIfAnyNumberMeetsThreshold([1, 2, 3], 10); // falsecheckIfAnyNumberMeetsThreshold([], 5); // falsecheckIfAnyNumberMeetsThreshold([100, 200, 300], 150); // true
Did you know?
TypeScript is not a language, it is a superset of JavaScript.
Test Cases
Input:
[ 1, 2, 3 ]
Expected Output:
false