title: How would I solve a coding puzzle with Javascript?
body: <p>There is a website called <a href="http://www.gild.com" rel="nofollow noreferrer">Gild.com</a> that has different coding puzzles/challenges for users to do. They can be completed in wide array of languages including Javascript. I am interested in solving these puzzles in Javascript, but I am unsure of the following:</p>
  
  <ul>
  <li>How am I supposed to access the input file which is supposed to be passed as an argument?</li>
  <li>How am I supposed to output the result?</li>
  </ul>
  
  <p>My understanding of Javascript is that it is run from within an HTML page and that output really is only in the form of placing values in the HTML, modifying the DOM, etc. For that reason it is not clear to me how Javascript can be used for solving these types of problems. Can someone who has used Gild before or has some insights into my question suggest how to proceed?</p>
  
  <p>An example of a problem would be: the given input file contains a positive integer, find the sum of all prime numbers smaller than that integer and output it.</p>
  
  <hr />
  
  <p><strong>EDIT:</strong> Some of the solutions below involve using external resources, but on Gild, I am supposed to put my solution in their editor and then submit it that way, like the following picture shows:</p>
  
  <p><img src="https://i.stack.imgur.com/NzFCF.png" alt="enter image description here"></p>
  
  <p>In other words, I don't think my solution can have access to Node.js or other external resources.</p>
  
  <hr />
  
  <p><strong>Edit:</strong> Here are some interesting articles that I have found that I think are the answer to my question:</p>
  
  <ul>
  <li><a href="http://www.phpied.com/installing-rhino-on-mac/" rel="nofollow noreferrer">http://www.phpied.com/installing-rhino-on-mac/</a></li>
  <li><a href="http://www.phpied.com/javascript-shell-scripting/" rel="nofollow noreferrer">http://www.phpied.com/javascript-shell-scripting/</a></li>
  </ul>