Cate wants to make a computer program be to be like the Magic 8 ball, in my last post, I couldn’t remember how to generate a random number. But found it here
Math is a class (not an object ), it has 2 class member functions.
which will give me a random decimal between 0 and 1, like 0.11, 0.34. If we take this and multiply by 6, then we will get a number between 0 and 6, but less than 6
will round off the decimal number to an integer.
Math.floor( Math.random() * 6)
So here is the program, which will magically give you an answer to any question you have in the word
This is a series that documents my daughter’s curiosity to learn about computer programming