Exercise 2: Greet Randomly
Greet in various languages.
We'll cover the following
Problem statement
Now, change the greet
method so that instead of always using "Hello "
, it picks a random string from the array ["Hello", "Hi", "Ohai", "ZOMG"]
.
Example
If the name “Ada”
is passed as an argument, then it should print out either "Hello Ada!"
, "Hi Ada!"
, "Ohai Ada!"
, or "ZOMG Ada!"
every time you run the program.
Note: You just need to provide the definition of the method, and it will be automatically evaluated on the given input value.
Try it yourself
To complete this task, you’re expected to either consult the documentation or look at the hint below.
# Start your code here