JavaScript Function to shuffle and display random all elements from Array click on button
<h1>Array Elements</h1> <script> const myArray = ['apple', 'banana', 'orange']; function displayArrayElements(array) { // Shuffle the array const shuffledArray = shuffle(array); // Create an array of li elements const liElements = shuffledArray.map(function(element) { // Create an li element const li = document.createElement('li'); // Set the text content of the li element to the current element li.textContent = element; return li; }); // Get the element to append the array elements to const element = document.getElementById('array-elements'); // Clear the element element.innerHTML = ''; // Append the li elements to the DOM liElements.forEach(function(li) { element.appendChild(li); }); } // Shuffle function function shuffle(array) { let currentIndex = array.length; let temporaryValue; …