clown <- function() {
bag <- c("mustang", "goat", "20 dollar bill")
cat("Hello, my name is Alfie!\n")
if (length(bag) == 0) {
sad_message <-"Sorry, the bag is empty!"
return(cat(sad_message))
}
gift_number <- sample(1:length(bag), size = 1)
gift <- bag[gift_number]
cat("Here, have a ", gift, "!", sep = "")
cat("\n\n")
# clown removes gift from bag:
bag <- bag[-gift_number]
}