I guess you mean `messages.splice(i, 1)` here? In what use case is this code reachable? I can't think of a use case where `index >= messages.length && messages[i].type == message.type`...