Chore Door Project // Only 3 possible combinations?

For the web dev path chore door project, it seems that the randomChoreDoorGenerator() function only produces three possible “random” outcomes. Although, for the example game provided, this is not the case.

Is this the expected outcome for the project – that only 3 possible door combinations are produced – or have I gone astray somewhere in my code: https://gist.github.com/2d87c986da50b2fe98b5c5fb641b15ca

Thanks!

Hello,

Yes, that’s the expected outcome based on the steps provided. The example site they link to has a bit more polish, so I consider that to be bonus challenge features that you can recreate if you wish.

If you look at the source of the site they link, it has 6 possible combinations instead of 3 in randomChoreDoorGenerator()

The source of their function if you'd like to see how they did it
//Next Steps - Switch Statement Version (6 possible combinations)
const randomChoreDoorGenerator = () => {
  choreDoor = Math.floor(Math.random() * 6);
  switch (choreDoor) {
    case 0:
      openDoor1 = botDoorPath;
      openDoor2 = beachDoorPath;
      openDoor3 = spaceDoorPath;
      break;
    case 1:
      openDoor1 = botDoorPath;
      openDoor2 = spaceDoorPath;
      openDoor3 = beachDoorPath;
      break;
    case 2:
      openDoor2 = botDoorPath;
      openDoor1 = beachDoorPath;
      openDoor3 = spaceDoorPath;
      break;
    case 3:
      openDoor2 = botDoorPath;
      openDoor1 = spaceDoorPath;
      openDoor3 = beachDoorPath;
      break;
    case 4:
      openDoor3 = botDoorPath;
      openDoor1 = beachDoorPath;
      openDoor2 = spaceDoorPath;
      break;
    case 5:
      openDoor3 = botDoorPath;
      openDoor1 = spaceDoorPath;
      openDoor2 = beachDoorPath;
      break;
  }
}
1 Like

Oh great! Thanks so much!

After staring at the code for a few hours, I figured it would be a good idea to get a second opinion.

Thanks for including their source code. That’s quite illuminating. I was imagining using Math.random again to give it a more random assignment somehow, but haven’t yet figured out how that would work exactly.

1 Like