I'm trying to create a word and number sorting program for a class final, but I can't get array.sort to work with an HTML element.
<textarea name="data" placeholder="Input data here:" class="inputBox" id="dataInput"></textarea>
// sorting words
//moving HTML input into array
function addDataWords() {
//clear dataOutput
let dataWords = [];
document.getElementById('dataOutput').innerHTML = '';
//push into array
dataWords.push(document.getElementById('dataInput').value.split(','));
console.log(dataWords);
//sort words
dataWords.sort();
console.log(dataWords);
document.getElementById('dataOutput').innerHTML = dataWords;
}
Debugger shows that HTML elements are being moved into the array, but .sort doesn't seem to sort them.