ALTERNATIVELY, we can also bite along the text as far as POSSIBLE before an error happens.
this language tries to bite off "pasta". if it can't, it tries to go as far as possible!
TRANSLATED:
it's easy. go along the text letter by letter. count how many letters match "pasta" until you get to one that doesn't match.
function travelPasta(text) {
let i = 0
while (i < text.length) {
if (text[i] !== "pasta"[i]) {
break
}
i++
}
return text.slice(0, i)
}
back to the dream