I need to sort the value of a textarea using arrays in JavaScript.
I tried this code but nothing happened:
var x = [];
x.push(myInput.value);
x.join("/n");
x = x.sort();
myOuput.value = x.toString();
My HTML code:
<textarea id="input"></textarea>
<p>
<textarea id="output"></textarea>
<p>
<button id="button">Click</button>
<p>
<div id="test"></div>
<script src="main.js"></script>
Edit: Thank you! All the answers were helpful to me and this is my code now:
var z = myInput.value.split('\n');
z = z.sort();
myOuput.value = z.join('\n');
joinwithout assignment makes no sense.