Javascript beginner here, I need to give an end user an option to randomize their inventory. I created a function to store the user's items but can't quite get the second function (shuffleFunction) working for randomization. I know there are a lot of examples out there, but I need help learning what I am specifically doing wrong in my second function. The console error reads (Uncaught TypeError: shuffleFunction is not a function at HTMLButtonElement.onclick).
This is for learning purposes.
<script type="text/javascript">
var items = [];
function myFunction()
{ "use strict";
var add = document.getElementById("collector");
items.push(document.getElementById("input").value);
add.innerHTML = items.join('<br/>');
}
var shuffleFunction = [ ];
function shuffleFunction()
{
while (items.length > 0) {
let rnd = Math.floor( Math.random( ) * items.length);
shuffleFunction.push( items[ rnd ] );
items.splice( rnd, 1 ); // remove position from old array
shuffle.push(document.getElementById("shuffle").value);
}
}
console.log( "Shuffled items: " + items );
</script>
<form>
<input id="input" type=text>
<input type=button onclick="myFunction()" value="Add Item"/>
<button id="shuffle" type="button" onclick="shuffleFunction()" value="Shuffle Items">Shuffle!</button>
<div id = collector >
</div>
</form>
Once the user types in their words, the user can then hit the shuffle button to randomize and display the array's results.