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<p id=display></p><script>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< 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 < 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 < 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() >= 0.5; };function inArray(needle, haystack) {    var length = haystack.length;    for(var i = 0; i < length; i++) {        if(haystack[i] == needle) return true;    }    return false;}display.innerHTML = generateSymmetricAscii();</script>
Generate Symmetric Ascii
javascript
Wheel re-useI Iike your usage of helper functions, inArray can be simplified by the use of indexOf: function inArray(x, xs) {return xs.indexOf(x) != -1}RepetitionYou repeat left_side.push(randomChoice twice. You should avoid repetition in code and state each concept or action once and just once.FPThis part of your code would benefit from Functional Programming:var total_array = left_side.concat(right_side);for(var i=0; i < total_array.length; i++) {    ascii_string += String.fromCharCode(total_array[i]);}return ascii_string;Becomes:return left_side.concat(right_side).map( String.fromCharCode).join();That looks much more declarative.