Skip to content
No description, website, or topics provided.
HTML JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Fortune aims to be a minimalist fortune script. Quotes / fortunes with equations in MathJax are supported.

How it works

Generate a quote

The fortune function gets a random fortune from the quotes array and writes it in the HTML document.

function fortune(){
  /* calculate a random index */
  index = Math.floor(Math.random() * quotes.length);
  /* display the quotation */
  document.write("<p>" + quotes[index] + "</p>");

To do so in the html just add:

<script type="text/javascript" src="js/fortune.js" type="text/javascript"></script>
<script type="text/javascript">fortune();</script>

Add a new quote or modify a quote

Open the fortune.js file and modify the quotes array.

Add MathJax support

Add the following code to support MathJax quotes:

    MathJax = {
        tex: {
            inlineMath: [
                ['$', '$'],
                ['\\(', '\\)']
<script src=""></script>
<script id="MathJax-script" async src=""></script>


To see what fortune.js can do for you, check the index.html file in the example folder.


You can’t perform that action at this time.