 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Finding the count of numbers divisible by a number within a range using JavaScript
Problem
We are required to write a JavaScript function that takes in a range of two integers as the first argument and a number as the second argument.
Our function should find all the numbers divisible by the input number in the specified range and return their count.
Example
Following is the code −
const range = [6, 57]; const num = 3; const findDivisibleCount = (num = 1, [l, h]) => {    let count = 0;    for(let i = l; i <= h; i++){       if(i % num === 0){          count++;       };    };    return count; }; console.log(findDivisibleCount(num, range)); Output
18
Advertisements
 