the first output is already altered by the method permute() but it shouldn’t be and I don’t know why.
Notice that the right output occurs when using javascript not with p5.js i.e :
I would like to have the both output in the console, before the permute() method and after.
let myTest = new classTest(1,2,3);
function setup() {
createCanvas(400, 400, WEBGL);
console.log(myTest.groupe); // should print [1,2,3] -> values get from constructor class. it doesn't
myTest.permute();
console.log(myTest.groupe); // should print [3,1,2] and it does
}
Both outputs in my browser got the expected values: [1, 2, 3] & [3, 1, 2].
But b/c you’re printing an array, if a browser by chance delays the actual printing to the console, it’s possible that you’ll see the array’s most current values for all outputs.
As a workaround you can extract the arrays values when printing it using the spread ... syntax: console.log(...myTest.groupe);
It appears that false output occurs only in the p5js editor. If I run the same code by simply editing files and opening the index.html directly with my browser it work perfecly well !
so, is this a fail in the p5js editor ? and by the way the problem seems to be fixed ?