Match the Last Item

Published by Matt in

Create a function that takes an array of items and checks if the last item matches the rest of the array concatenated together.

Examples

match_last_item(["rsq", "6hi", "g", "rsq6hig"]) ➞ true
# The last item is the rest joined.

match_last_item([1, 1, 1, "11"]) ➞ false
# The last item should be "111".

match_last_item([8, "thunder", true, "8thundertrue"]) ➞ true

Notes

The array is always filled with items.

Watch a quick demo on how Edabit works.