How do I insert text into a Monaco Editor? : <p>I have a monaco code editor embedded in my app.</p>

<p>How do I programmatically insert text on a particular line?</p>

<pre><code>var editor = monaco.editor.create(document.getElementById("container"), {
    value: "// First line\nfunction hello() {\n\talert('Hello world!');\n}\n// Last line",
    language: "javascript",

    lineNumbers: false,
    roundedSelection: false,
    scrollBeyondLastLine: false,
    readOnly: false,
    theme: "vs-dark",
});
// how do I do this?
editor.insertText("FOO");
</code></pre>
