Hello everyone, it’s impossible to come up with an algorithm for sequentially performing n functions. There is an array (two-dimensional) to which you want to apply all the functions from another array.
Details: we have a matrix with which it is possible to perform the following actions (transposing, rearranging rows, rearranging columns, rearranging areas), the number of actions is for example 10, and so because of asynchrony, the functions are performed immediately and the matrix is broken, but you need to start a new
var useNetwork = [] //матрица со стороной 9х9 var fL = [ function(){ //transponding if(debug) console.log('transponding start'); for(i=0;i<9;i++){ for(j=0;j<9;j++){ useNetwork[j][i] = useNetwork[i][j]; } } if(debug) console.log('transponding end'); }, function(){ console.log('second'); }, function(){ console.log('third'); }, function(){ console.log('fourth'); } ]; for(i=0;i<10;i++){ nameOfFunction = fL[parseInt(Math.random() * (4 - 0) + 0)]; nameOfFunction(); } throws the following into the console
index.html:246 fourth index.html:225 transponding start index.html:233 transponding end
Array.prototype.mapto help you - Dmitriy Simushevrandomimplicated. Anything else? Let's do it right away. - Igor