- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Getting equal or greater than number from the list of numbers in JavaScript
We are required to write a JavaScript function that takes in an array of numbers as the first argument and a single number as the second argument. The function should return an array of all the elements from the input array that are greater than or equal to the number taken as the second argument.
Example
Following is the code −
const arr = [56, 34, 2, 7, 76, 4, 45, 3, 3, 34, 23, 2, 56, 5]; const threshold = 40; const findGreater = (arr, num) => { const res = []; for(let i = 0; i < arr.length; i++){ if(arr[i] < num){ continue; }; res.push(arr[i]); }; return res; }; console.log(findGreater(arr, threshold));
Output
This will produce the following output in console −
[ 56, 76, 45, 56 ]
- Related Articles
- How to get the smallest integer greater than or equal to a number in JavaScript?
- Select equal or nearest greater number from table in MySQL
- JavaScript: Finding nearest prime number greater or equal to sum of digits - JavaScript
- Python - Number of values greater than K in list
- Complete the following statements:The probability of an event is greater than or equal to …………. and less than or equal to ………..
- Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold in C++
- How to find numbers in an array that are greater than, less than, or equal to a value in java?
- List six rational numbers less than $-2$ but greater than $-3$.
- Python – Find the frequency of numbers greater than each element in a list
- A die is thrown. Find the probability of getting a number greater than (5).
- First element greater than or equal to X in prefix sum of N numbers using Binary Lifting in C++
- Smallest prime number just greater than the specified number in JavaScript
- An angle is greater than ( 45^{circ} ). Is its complementary angle greater than ( 45^{circ} ) or equal ( 45^{circ} ) or less than ( 45^{circ} ? )
- An angle is greater than $45^{circ}$. Is its complementary angle greater than $45^{circ}$ or equal to $45^{circ}$ or less than $45^{circ}$?
- How to apply Greater Than or Equal operation on the elements of two series objects?

Advertisements