+ 7
Code not compatible ?
So let's say that in python I have this function called rotate_90(m) that will take a matrix m and rotate its terms 90 degrees clockwise. Now if I want to make the function rotate_270(m), knowing that 270=9*3 I'll do: def rotate_270(m): for i in range(3): m=rotate_90(m) return m Now let's say I have this same function rotate_90(m) but in javascript. If I try to do function rotate_270(m){ for(i=0;i!=3;i++) m=rotate_90(m) return m } For some reason it doesn't seem to work.... Could somebody tell me why please ?
4 Answers
+ 5
maybe try:
for( var i=0; i < 3; i++)
m=rotate_90(m)
I donât think this will fix the problem though, it should just make i a local variable, but maybe thatâs the issue?
+ 9
Indeed I tried with for(let i=0;i!=3...etc) and it worked ! Thank you Jackson OâDonnell !
+ 8
Jackson OâDonnell sorry my question wasn't clear....
So in python it works but not in javascript: in javascript I believe that it runs forever because if I alert the output, that alert will never show up...
+ 1
is the rotate_90(m) written in JS as well? It may be an issue in that function. And what is your error? Does it just not run? Run forever? Wrong output?