title: How to Solve modulo using recursion(can't use *, %, / or Math operator)
body: <p>Below is my code which works perfectly fine, except that I am not allowed to use '*' operator. But in that case, I don't know how to convert the negative number to positive for comparison. One option is to use Math.abs but I am not allowed to use that either.</p>
  
  <pre><code>var modulo = function(x, y) {
  
      if ( x === 0 &amp;&amp; y ===0 ) return NaN;
      if ( x === y ) return 0;
      if ( x === 0 ) return 0;
      if (x &gt; 0 &amp;&amp; y &gt; 0) {
          return x &lt; y ? x : modulo(x-y,y);    
      }
  
      if ( x &lt; 0 &amp;&amp; y &lt; 0 ) {
  
          return x*-1 &lt; y*-1 ? x : modulo(x-y,y);
      }
  
      if( x &gt; 0 &amp;&amp; y &lt; 0 ) {
          return x &lt; y*-1 ? x : modulo(x+y,y);    
      }
  
      if ( x &lt; 0 &amp;&amp; y &gt;0) {
          return x*-1 &lt; y ? x : modulo(x+y,y);
      }
  };
  </code></pre>