title: Prime Factorisation in Javascript
body: <p>I need to write a prime factorisation function that returns an object whose keys are a prime factor and values are the exponents of the corresponding prime factors. E.g.</p>
  <p>console.log(primeFactorisation(4)) // { 2: 2 }
  console.log(primeFactorisation(6)) // { 2: 1, 3: 1 }</p>
  <p>My code so far is below but I'm stuck. Any help much appreciated.</p>
  <pre><code>const primeFactorisation = (num) =&gt; {
      let result = {};
      for (let i = 2; i &lt; num; i++) {
        if (num % i === 0) {
          result[i] = i;
          num /= i;
        }
      }
      return result
    }
  </code></pre>