title: How can I turn my JavaScript code into a bookmarklet?
body: <p>I currently only understand the very basics of bookmarklets. For example, I know that to create a bookmarklet that simply creates an alert, you would use the code</p>
  
  <pre><code>&lt;a href="javascript:(function() { alert(); })()"&gt;Drag Me To Bookmarks&lt;/a&gt;
  </code></pre>
  
  <p>However, what if you have more complex javascript, with multiple helper methods? For example, as I wanted to create some javascript code to give the alert "Good Morning" or "Good evening" depending on the time of day. Suppose also that I do this using 2 functions, as shown below</p>
  
  <pre><code>function getMessage() {
     if(morning) {
        return "Good Morning";
     } else if(evening) {
        return "Good Evening";
     }
  }
  
  function myAlert() {
     alert(getMessage());
  }
  </code></pre>
  
  <p>How would this be turned into a bookmarklet now that the JS has multiple functions?</p>