lundi 3 mai 2021

Else if not returning the right value, always 1/4 of each gender

I modified a github code by adding additional genders. This function should return an image with the right gender. I have added two genders but the code always gives me a random gender. I already checked the board but didn't find anything simmilar. the problem I have is that this condition always gives me 1/4 of each gender. But I think there should be less Zombies and Aliens than male and female images.

  var integer = getRandomInt(1000)

  if (integer >= 500) {
    return "Female";
  } else if (integer == 1) {
    return "Zombie";
  } else if (integer == 2) {
    return "Alien";
  } else {
    return "Male";
  }
}

Aucun commentaire:

Enregistrer un commentaire