you need to make the error message for the "two" term better.
if you make a mistake with the second term, it should tell you that you at least got the first term right.
TRANSLATED:
it's easy. if the first term fails, give the error for that one. if the second term fails, give the error for that one.
class TwoTerm extends Term {
//...
error(text) {
const [bite1, tail1] = this.term1.eat(text)
if (bite1 === null) {
return this.term1.error(text)
}
const bite2 = this.term2.bite(tail1)
if (bite2 === null) {
return this.term2.error(tail1)
}
return null
}
}
back to the dream