Here are my comments in a workable form in a jsfiddle:
Other than some small changes I made to make the jsfiddle work (like adding jquery as a library because document.write isn’t allowed in jsfiddle, and like making the click events be handled by jquery, and like adding <br />
tags at the end of each sequence of characters), it works as you described.
var FromStart = 0
document.write("|");
for (i = 0; i < FromStart; i++) {
document.write("_");
}
document.write("O");
for (i = 0; i < 30-FromStart; i++) {
document.write("_");
}
document.write("|<br />");
function Left() {
FromStart += -1;
document.write("|");
for (i = 0; i < FromStart; i++) {
document.write("_");
}
document.write("O");
for (i = 0; i < 30-FromStart; i++) {
document.write("_");
}
document.write("|<br />");
}
function Right() {
FromStart += 1;
document.write("|");
for (i = 0; i < FromStart; i++) {
document.write("_");
}
document.write("O");
for (i = 0; i < 30-FromStart; i++) {
document.write("_");
}
document.write("|<br />");
}