Hitting the Jackpot

Published by Helen Yu in

Create a function that takes an array (slot machine outcome) and returns true if all elements in the array are identical, and false otherwise. The array will contain 4 elements.

Examples

test_jackpot(["@", "@", "@", "@"]) ➞ true

test_jackpot(["abc", "abc", "abc", "abc"]) ➞ true

test_jackpot(["SS", "SS", "SS", "SS"]) ➞ true

test_jackpot(["&&", "&", "&&&", "&&&&"]) ➞ false

test_jackpot(["SS", "SS", "SS", "Ss"]) ➞ false

Notes

The elements must be exactly identical for there to be a jackpot.

Watch a quick demo on how Edabit works.