How to pass an array through Javascript Function Arguments -


i have found couple other similar threads on stackoverflow (pass array thread 2) , (pass array thread 1) few other sites either did not understand them, did not answer question, or did not know how implement code.

i have following code should create map game based on arrays:

function createmap(level) {    var map = document.getelementbyid('map');    mapwidth = parseint(level[0]);    mapheight = parseint(level[1]);    map.innerhtml = '';    rownumber = 1;    tileid = 1;    var consolehelp = level[7];    console.log(k+' , value '+consolehelp);    k = 1; (k = 1; k <= mapheight; k++) { // repeat below loop until specified height reached  (k = 1; k <= mapwidth; k++) { // create row of tiles based on specified width of array     console.log('row '+k+' created')     if (rownumber == 1) {         k++;     }     else {         k--;     }     if (level[k] == 'w') {         map.innerhtml += '<span id="'+rownumber+'-'+tileid+'">desert<image class="tiles" src="desert.png"></span>';     }     else if (level[k] == 'g') {         map.innerhtml += '<span id="'+rownumber+'-'+tileid+'"><image class="tiles" src="grass.png"></span>';     }     else {         console.log('crap dis did not work');         var consolehelp = level[k];         console.log(k+' , value '+consolehelp);     }     if (rownumber == 1) {         k--;     }     else {     k++;     }     tileid++   }   rownumber++   level = level + '_1';   map.innerhtml = "<br>"; } spawntile(); } 

and variable arrays (incomplete idea):

var map_beginning_1 =         ['20','10','w','w','w','w','w','w','w','w','w','w','w','w','w','w','w','w','w','w','w','w']; var map_beginning_1_1 =                 ['w','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','w']; 

my problem call in

createmap('map_beginning_1') 

and nothing happens. there's no errors nothing else happens. did test see getting , value of "level[7]" "i" , "level1" "a", location of characters in "map_beginning_1". can please explain me how or if it's possible variably pass array through javascript function argument , how it? , if isn't possible, can suggest alternatives i'm trying do? javascript preferable can use jquery if must.

you have passed string function , not variable please try following, removing single quotes.

createmap(map_beginning_1);