title: Normalisation of numbers using javascript
body: <p>I want to normalise the numbers to range of 0 to 10 .. with outlier exclusion.</p>
  
  <p>Example: </p>
  
  <pre><code>var arr = [100,200,19,0,200,12,20000]
  
  normalise(arr,200); // should be 10
  normalise(arr,12); // should be 0.6
  
  // My expected output for above array:
  [5, 10, 0.95, 0, 10, 0.6, 10]
  </code></pre>
  
  <p>Below is the sample code  using python , which is exactly what I am looking for. </p>
  
  <pre><code> arr = np.array([100,200,19,0,200,12,20000])
   upper_lim = np.median(arr) * 2
   arr_adj = np.where(arr&gt;upper_lim, upper_lim, arr) / upper_lim
   arr_adj *= 10
  </code></pre>
  
  <p>I tried to convert it to javascript like below , I am new  to javascript.</p>
  
  <pre class="lang-js prettyprint-override"><code>function normalise(arr, value) {
    var arr = [100, 200, 19, 0, 200, 12, 20000]
    var upperlimit = median(arr) * 2;
    //I am struck here 
    return normal * 10;
  }
  
  function median(numbers) {
    var median = 0,
        count = numbers.length;
  
    numbers.sort();
  
    if (count % 2 === 0) { // is even
      median = (numbers[count / 2 - 1] + numbers[count / 2]) / 2;
    } else { // is odd
      median = numbers[(count - 1) / 2];
    }
  
    return median;
  }
  
  normalise(arr, 200); // should be 10  
  </code></pre>
  
  <p>Please help me convert this to javascript, thank you.</p>
  
  <pre><code>np.where(arr&gt;upper_lim, upper_lim, arr) / upper_lim;
  </code></pre>