Write a function that takes three string arguments (first, last, word)
and returns true
if (when alphabetically sorted) word
is found between first
and last
.
Examples
isBetween("apple", "banana", "azure") ➞ true
isBetween("monk", "monument", "monkey") ➞ true
isBetween("bookend", "boolean", "boost") ➞ false
Notes
All letters will be in lowercase.
function isBetween(first, last, word) {
let arr = [first, word, last ]
return arr.join("") === arr.sort().join("")
}
Problem Url: https://edabit.com/challenge/j63YSGGK9xoLiXCKF