textContent not updating HTML
<p>Using Javascript I have created a script to generate random text in a paragraph. It works. When I print to the console I see a paragraph of text.</p>

<pre><code>console.log(randParagraph(sentLength(5,8), '', ipsumText, sentLength(5,12)));
</code></pre>

<p>Now I want to update some text in an html file with that paragraph on click of a button. The below is how I thought it should be done. </p>

<pre><code>const randParagraph = (len, end, words, wordLen) =&gt;
[...Array(len)].map(() =&gt; addCommaAfter(fullSentWithEnd,sentLength(3,8)))
.join(' ') + (end || '');


function myFunction() {
var x = (randParagraph(sentLength(5,8), '', ipsumText,sentLength(5,12)));
var y = document.getElementById("ipsum-text").textContent = "x";
}
</code></pre>

<p>My assumption is if console.log works, I should store that result in a variable which is what I'm trying to do with var x.</p>

<p>Then in var y I can use getElementById to change the html text. </p>

<pre><code>&lt;button onclick="myFunction()"&gt;change text&lt;/button&gt;

&lt;p class="bodyCopy" id="ipsum-text"&gt;gimme some ipsum&lt;/p&gt;
</code></pre>

<p>Is this the correct way to go about it? It's not working.
I know one would use jquery to do this, but I haven't learned it yet. I'm still learning javascript.</p>