Build the core of a plain-text editor as a TextEditor class.
new TextEditor() starts with empty text and the cursor at 0. The cursor sits between characters. 0 is before the first character, and text.length is after the last one.
Input: ed.type("helo"); ed.moveLeft(1); ed.type("l")
[ed.getText(), ed.getCursor()]
Output: ["hello", 4]
Input: ed.backspace(2)
[ed.getText(), ed.getCursor()]
Output: ["heo", 2]backspace returned 2
It comes in 3 parts, each building on the last: Typing and the cursor, Undo, Redo.