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 

Closed due to the fact that off-topic participants Dmitriy Simushev , Grundy , zRrr , Kromster , aleksandr barakin 9 Jun '16 at 13:39 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Grundy, zRrr, Kromster, aleksandr barakin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Array.prototype.map to help you - Dmitriy Simushev
  • one
    and what, it is impossible for the operator to bypass all functions? - nick_n_a
  • one
    @ user3535225 - sacramental: "You do not negotiate something." - Igor
  • one
    @ user3535225 - well, it starts. Where in your code asynchrony? - Igor
  • 2
    @ user3535225 "The Queen is in awe!" Now it turns out here also random implicated. Anything else? Let's do it right away. - Igor

1 answer 1

From here I took my “filling apple on a silver platter” from the shelf and looked at what was shown on the educational channel. I bet your code will work when you add a var in front of your cycles in front of the counter.

 for(var i=0;i<10;i++){ ... } 
  • Alas, in the code the var is present, just hurry when added here and made a blot. - user3535225
  • @ user3535225 Are you kidding? - Igor
  • no way, instead of smiles and well-known quotes, it is probably better to help) if this is your goal - user3535225