javascript pick random line from a textarea

  input, javascript, line, random, textarea

I’m trying to get a javascript pick a random line from a textarea. Sorry, big noob here.

Currently my code looks like this, and I’m quite sure there are silly mistakes in it. I’m just kinda stuck. First, how do I connect this function to the textarea? Secondly, how do I even output the result?
I think I’ve done too much there with making it two functions. I don’t mind making it smaller somehow.

<div class="container">
    Enter all of the names on a seperate line. <br />
<textarea id="textarea" placeholder="Enter names here..."></textarea>   
<h3>The winner is: <span id = "winner"></span></h3>
<button onclick="randomSelect()">Click me</button>

function randomSelect() {
const lines = input.split('n');
const randomLine = lines[Math.floor(Math.random() * lines.length))];

function selectOutput() {
document.getElementById("winner").innerHTML = ;

Source: Ask Javascript Questions