Random Picker Coding Help

I am trying to help a group of students to write code to randomly select one user input from two options. Is this possible? App project link below.

Link to the project or level: [Code.org - App Lab
What I expect to happen: Students want one user input to be randomly selected

Hi @ctaylor,

Yes. You can! I’ll walk you through the pseudocode as I see it and I hope that will help you see the solution.

  • Because this is somewhat of a contained set of actions, I would create a separate function.
  • Next, I would create a variable that generates a random number based on how many choices there are.
  • If one of the numbers is chosen, you would then set the property of the desired text box with the text from the text box the users entered their choices into.
  • The other box is set to the other option.
  • Make sure you call the function in the event that should trigger the random number generation.

That’s how I see it:) I hope it helps. I believe this is a post for CSP - for the Decision Maker project. I will move the post there to CSP if you have follow-up questions.

~Michelle

Thank you! I teach using a modified CSD. I will check out the other course.

Oh…I see. Let us know if you have covered those concepts (functions, random number, conditionals). If not, we can support you with more detail.

I understand some of this and created code to hide and show a checkmark next to the user input. I think isn’t correct though, because it keeps showing the same checkmark.

@ctaylor,

From what I can tell, it appears to be working now, so you may have figured it out. The only thing I can see is that if you continually press go without pressing clear in between, it can appear as if both options are checked, but otherwise, I think you have it figured out!

Nice!

Mike

I did finally figure it out! Thanks!

2 Likes