Division without using division, multiplication, or modulus operators The task


  Implement division of two positive integers without using the
  division, multiplication, or modulus operators. Return the quotient as
  an integer, ignoring the remainder.


My solution

const division = (dividend, divisor) =&gt; {
    let remainder = null;
    let quotient = 1;
    const sign = ((dividend &gt; 0 &amp;&amp; divisor &lt; 0) || 
                 (dividend &lt; 0 &amp;&amp; divisor &gt; 0)) ? 
                 ~1 : 1;

    let tempdividend = Math.abs(dividend);
    let tempdivisor = Math.abs(divisor);

    if (tempdivisor === tempdividend) {
        remainder = 0;
        return sign;
    } else if (tempdividend &lt; tempdivisor) {
        remainder = dividend &lt; 0 ? 
            sign &lt; 0 ? ~tempdividend : tempdividend : 
            tempdividend;
        return 0;
    }
    while (tempdivisor &lt;&lt; 1 &lt;= tempdividend) {
        tempdivisor = tempdivisor &lt;&lt; 1;
        quotient = quotient &lt;&lt; 1;
    }

    quotient = dividend &lt; 0 ? 
        (sign &lt; 0 ? ~quotient : quotient) + division(~(tempdividend-tempdivisor), divisor) :
        (sign &lt; 0 ? ~quotient : quotient) + division(tempdividend-tempdivisor, divisor);
    return quotient;
 }
Is bitwise operation mandatory? There's a much simpler way

const divide = (dividend, divisor) =&gt; {
     let quotient = 0, neg = false;

     if( (dividend &lt; 0 &amp;&amp; divisor &gt; 0) || (dividend &gt; 0 &amp;&amp; divisor &lt; 0) ){ neg = true; }

     dividend = Math.abs(dividend);
     divisor = Math.abs(divisor);

     if(dividend &lt; divisor) {return 0;}
     else if(dividend &gt; 0 &amp;&amp; divisor != 0){
          while(dividend &gt;= divisor){
               dividend -= divisor;
               ++quotient;
          }
     } else { // handle what you want to do for those cases..}

     return neg ? -quotient : quotient;
}


You get your quotient and remainder is ignored. Just do a check if dividend is negative or divisor is 0.