mercredi 29 juin 2022

Generate same random number based on string parameter

I'm trying to create a function that will generate the same random number on each execution if the string is the same.

function generateRandom(maxInt, stringParam) {
  //generate random based on stringParam
  //output int number from 0 to maxInt
}

The goal is to generate the same random number (on different pages) if the stringKey is the same.

generateRandom(100, 'abc') // 73
generateRandom(100, 'abc') // 73
generateRandom(100, 'abc') // 73

generateRandom(100, 'qwe') // 45
generateRandom(100, 'qwe') // 45
generateRandom(100, 'qwe') // 45



Aucun commentaire:

Enregistrer un commentaire