title: Struggling to understand how these functions work
body: <p>I've been trying to understand how these functions I found online work for a couple of days now and I really can't wrap my head around them:</p>
  
  <pre><code>var gcd = function (a, b) {
      return a ? gcd(b % a, a) : b;
  }
  var lcm = function (a, b) {
      return a * b / gcd(a, b);
  }
  </code></pre>
  
  <p>Use reduce on an array of integers and these functions somehow calculate the the smallest common multiple of all numbers in the array.</p>
  
  <p><code>[1, 2, 3, 4, 5].reduce(lcm); // Returns 60</code></p>
  
  <p>I understand basic JavaScript so I obviously know what a function and a variable are but I don't understand how exactly the ? and : operators work in this context. I know they operate similarly to switch statements using boolean values to determine which code should run based on the conditions specified before and after the colon but neither function seems to be taking any arguments at all that could be true or false. How could <code>b</code> be a percentage of <code>a</code> if <code>a</code> is never defined? I don't understand how any of this works, how do these functions even run and return a correct answer?</p>