title: Finding Gapful number in javascript
body: <blockquote>
    <blockquote>
      <p>A number is gapful if it is at least 3 digits long and is divisible by the number formed by stringing the first and last numbers together.
      The smallest number that fits this description is 100. First digit is
      1, last digit is 0, forming 10, which is a factor of 100. Therefore,
      100 is gapful.</p>
    </blockquote>
    
    <p>Create a function that takes a number n and returns the closest gapful
    number (including itself). If there are 2 gapful numbers that are
    equidistant to n, return the lower one.</p>
    
    <p>Examples gapful(25) ➞ 100</p>
    
    <p>gapful(100) ➞ 100</p>
    
    <p>gapful(103) ➞ 105</p>
  </blockquote>
  
  <p>so to solve this i wrote the code that loops from the given number to greater than that and find out if it is or not by</p>
  
  <pre><code>function getFrequency(array){
      var i=array
      while(i&gt;=array){
          let a=i.toString().split('')
          let b=a[0]+a[a.length-1]
          b= +b
          if(i%b==0) return i
          i++
      }
  }
  console.log(getFrequency(103))
  </code></pre>
  
  <p>Thats fine but what if the gapful number is less than the number passed in the function ?
  like if i pass 4780 the answer is 4773 so in my logic how do i check simultaneoulsy smaller and greater than the number passed ?  </p>
  
  <p>I am only looping for the numbers greater than the number provided in function</p>