title: Replace numbers by a calculation in Javascript
body: <p>I would like to know if there's a way in javascript to replace <strong>[0]</strong> by 
  a calculation : <strong>[+1]</strong> and <strong>[-1]</strong><br /></p>
  
  <p>Example of my situation :<br />
  I have a gallery presenting 6 images, I want to use keyboard arrows to navigate.<br />
  When the current image is the 4th, if I let <strong>[1]</strong> in my script to go to the previous image by pressing keyboard arrow, the first image appears instead of the third.<br />
  Any idea ? Thanks.</p>
  
  <p>Script :</p>
  
  <pre><code>$(document).on('keyup', function (e) {
      switch (e.which) {
          case 37:
              $('.prev')[0].click();
              break;
  
          case 39:
              $('.next')[0].click();
              break;
      }
  });
  </code></pre>