mardi 17 décembre 2019

Make two functions use the same number (generated by findRandom) in Typescript

The problem now I'm facing is functions call findRandom twice and get two different value at the end. How to make findRandom randomly pick a number and store it at one place where the number will be unchanged.

Expected result: all the functions share the same number or value.

getRandom = a.findRandom(0,1);
storeRandom = getRandom; 

functionA() {
   if (storeRandom = 0){
       console.log("0");
   }
}

functionB(){
    if (storeRandom = 1){
        console.log("0");
    }
}



Aucun commentaire:

Enregistrer un commentaire