Generate Symmetric Ascii Have you got any suggestions to improve this code?
The idea is to generate a one-line string that is visually symmetric.

Revisions at Github

&lt;p id="display"&gt;&lt;/p&gt;

&lt;script&gt;
var display = document.getElementById('display');

var chars = [33,34,39,42,43,45,46,48,58,61,72,73,77,79,84,92,94,95,111,124];
var double_chars = [40,41,47,92,60,62,91,93,123,125];
var double_chars_assoc = {40:41,47:92,60:62,91:93,123:125,
41:40,92:47,62:60,93:91,125:123};

function generateSymmetricAscii() {
    var ascii_string = "";
    var left_side = [];

    for(var i=0; i&lt; randomInt(2,50); i++) {
        if(randomBool() == true) {
            left_side.push(randomChoice(chars));
        }
        else {
            left_side.push(randomChoice(double_chars));
        }
    }

    var right_side = left_side.slice(0);
    right_side.reverse();

    for(var i=0; i &lt; right_side.length; i++) {
        if(inArray(right_side[i], double_chars) == true) {
            previous_char = right_side[i];
            right_side[i] = double_chars_assoc[previous_char];
        }
    }

    var total_array = left_side.concat(right_side);

    for(var i=0; i &lt; total_array.length; i++) {
        ascii_string += String.fromCharCode(total_array[i]);
    }
    return ascii_string;
}

function randomInt(min, max) { return Math.floor(min + (Math.random() * (max - min))); }
function randomChoice(choices) { return choices[randomInt(0, choices.length-1)]; }
function randomBool() { return Math.random() &gt;= 0.5; };
function inArray(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i &lt; length; i++) {
        if(haystack[i] == needle) return true;
    }
    return false;
}

display.innerHTML = generateSymmetricAscii();

&lt;/script&gt;
Omit the extra == true in conditions:

if(randomBool())


Use the ternary if operator to compact your code:

left_side.push(randomChoice(randomBool() ? chars : double_chars))


If this seems to dense for you, you can also extract the inner expression like this:

var options = randomBool() ? chars : double_chars;
left_side.push(randomChoice(options))