-
• #2
Have you tried using modulo
%
instead ofMath.wrap()
? -
• #4
I just wondered that it was different in a program and in the console.
Because in line 80 it is 9, and in line 82 it is 0. -
• #5
Maybe I'm misunderstanding...
Math.wrap
will return a number between 0 and 9, even though at line 80 in the code above,k
itself will be somewhere around40
.In your uploaded code:
for(var j = 0; j < 30; j++) { tmp[i] = i; console.log('k = ' + k +' ' + 'i = ' + i); Math.wrap(k++, 10); i++; if(i > 9) {i = 0;} }
The return value of
Math.wrap
isn't being used, so you might as well be doing:for(var j = 0; j < 30; j++) { tmp[i] = i; console.log('k = ' + k +' ' + 'i = ' + i); k++; i++; if(i > 9) {i = 0;} }
I have problems with Math.wrap.
When I run it in a program, it does not wrap, but if I enter it in the console it wraps it ok.
On a Pico