Hi @anna1, you can find some good examples for generating random numbers on the Mozilla web docs page. Note the inclusive and exclusive min and max, respectively.
Generating random integer between two values
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
mTurk = getRandomInt(1000000, 9999999)
Saving data using PsychoJS
psychoJS.experiment.addData("mturk", mturk)