Basic While Loops - Write words Version 4 - Prompted number of Random Words chosen!

Writes each word as it gradually builds up a number of random words (a number ENTERED BY THE USER) - until all words have been written. As always it uses while loops, and if statements.

^^ THE random WORDS ARE WRITTEN HERE

This example of randomness randomly chooses x number of words from a total of 7 possible word choices.
Because this is relatively uncontrolled randomness, this example does NOT prevent the same word being randomly chosen more than once.




NOTE:
If the alert wasn't happening between each loop iteration, the words would be written extremely quickly.

So if you want the loop just to create/execute something quickly, take the alerts out.

But if you want the loop to execute more slowly, the easiest solution is to EITHER:
- Keep the alerts
OR
- Use a different method and NOT a loop (it is hard to safely slow loops down - crashes and errors tend to result).
      (a good way to get a slower effect could be a JS setTimeout [see the week 11 section of the Resources page] which calls a function that builds something up step by step in a global variable)