Project Euler Problem #7 : 10001st prime

My solution for Problem #7 on projecteuler.net

by Hilarius Doren

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<div class="code">
    <a href="https://projecteuler.net/problem=7">Project Euler</a> Solution
    <br/>Problem ID #7 : 10001st prime
    <br/>
    <br/>By listing the first six prime numbers: 
    <br/>2, 3, 5, 7, 11, and 13,
    <br/>we can see that the 6th prime is 13.
    <br/>
    <br/>What is the 10,001st prime number?
    <br/>
</div>
<div id="main">
    <br/>Please enter the target number for this exercise:
    <br/>
    <br/><input type="text" id="txtTarget" value="10001" size="15" />
    <br/>
    <br/><button type="button" onclick="getResult()">Click for Results</button>
</div>

<script>
    //my javscript functions
    
    //ARRAY FUNCTIONS
    function sumArray(theArray) { return theArray.reduce(function(prev, curr) { return prev + curr; }); }
    function emptyArray(theArray) { while (theArray.length > 0) theArray.pop(); }
    
    //MATH FUNCTIONS
    //some of consecutive squares (1^2 + 2^2 + ... + 10^2)
    //last modified on 2015-07-22
    function SumOfConsecutiveSquares(num) {
        return Math.round((num/6)*(num+1)*((2*num)+1));
    }
    
    //sum of consecutive digits - that has its uses
    //last modified on 2015-07-16
    function SumOfIntegers(num) { return num * (num+1) / 2; }
    
    //my version of Lowest Common Multiple - again lots of exercises seem to want this or some variant
    //I found this on the internet - it can be a bit confusing, especially the fact that the use of 
    //for loops is doing the bulk of the math updates in atypical fashion
    //last modified on 2015-07-15
    function LCM(theArray) {
        for (var d, i, j, n, r = 1; (n = theArray.pop()) !== undefined;) {
            while (n > 1) {
                if (n%2) {
                    for (i = 3, j = Math.floor(Math.sqrt(n)); i <= j && n%i; i+=2);
                    d = (i <= j) ? i : n;
                } else d = 2;
                for (n /= d, r *= d, i = theArray.length; i; 
      ...

CSS

.code {
    font-family:'Courier';
    font-size: 12px;
    color: #000;
    background: #D0D0D0;
    padding: 10px 25px;
}

JavaScript

//this uses the isPrime function in my script library
//it also uses the knowledge that after 3, all prime numbers come from the pool of
//6n +/- 1 : so n = 1, so 6n +/1 is 5 or 7, n = 2 = 11,13... and while occasionally
//one of those numbers isn't prime - all of the prime numbers will come from them...

function getResult() {
    var target = +document.getElementById('txtTarget').value;
    var primeArray = [2,3];        //we'll start with the first two primes
    for (var n = 6; primeArray.length < target; n += 6) {
        if (isPrime(n-1)) primeArray.push(n-1);
        if (isPrime(n+1)) primeArray.push(n+1);
    }
    console.log(primeArray[target-1]);
}