1
var TextEditor = function () {10
TextEditor.prototype.addText = function (text) {11
for (let letter of text) {12
this.forward.push(letter);20
TextEditor.prototype.deleteText = function (k) {22
while (this.forward.length && deleted < k) {33
TextEditor.prototype.cursorLeft = function (k) {35
while (this.forward.length && moved < k) {36
this.backward.push(this.forward.pop());39
return toTheLeft(this.forward);46
TextEditor.prototype.cursorRight = function (k) {48
while (moved < k && this.backward.length) {49
this.forward.push(this.backward.pop());52
return toTheLeft(this.forward);55
function toTheLeft(arr) {57
for (let i = Math.max(0, arr.length - 10); i < arr.length; i++) {60
let res = letters.join("");