Skip to contents

Flip a coin

Usage

play_coin_flip(
  n = NULL,
  animate = rlang::is_interactive(),
  header = rlang::is_interactive()
)

Arguments

n

How many coins to flip. Defaults to NULL, which interactively asks how many to flip.

animate

If TRUE, play an animation before revealing the result. Defaults to TRUE if the session is interactive and FALSE otherwise.

header

If TRUE, prints a header for the game. Defaults to TRUE if the session is interactive and FALSE otherwise.

Value

A character vector of "heads" or "tails" results.

Examples

play_coin_flip(1)
#>
#> Tails

if (rlang::is_interactive()) play_coin_flip()