title: Unless vs if in Javascript with use of exclamation point?
body: <p>The code below attempts to print out "is even" for numbers divisible by 2. </p>
  
  <p>Should it not be if (test) then() rather than: if (!test) then(), when condition tested is "n % 2". The code below seems to read "IF numbers are NOT divisible by 2, print out 'number is even' ", which does not seem logical.</p>
  
  <p>More generally speaking, what are the advantages of writing an Unless function over using an If statement in specifying condition, when what we could do is simply write if (!condition)? </p>
  
  <p>Any help is much appreciated.</p>
  
  <pre><code>function unless(test, then) {
    if (!test) then();
  }
  function repeat(times, body) {
    for (var i = 0; i &lt; times; i++) body(i);
  }
  
  repeat(5, function(n) {
    unless(n % 2, function() {
      console.log(n, "is even");
  });
  // → 0 is even
  // → 2 is even
  // → 4 is even
  </code></pre>