screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <title>Array to Set Conversion</title> <script> // JavaScript code function convertArrayToSet() { const array = ['a', 'a', 3, 4, 4, 5, 5]; // Display the original array in the webpage document.getElementById('originalArray').innerHTML = "Original Array: " + array; // Create a new Set from the array const set = new Set(array); // Convert set to an array const convertedArray = Array.from(set); // Display the converted array in the webpage document.getElementById('convertedArray').innerHTML = "Converted Array: " + convertedArray; } // Trigger the conversion when the page loads window.addEventListener('load', convertArrayToSet); </script> </head> <body> <h3>Javascript Convert Array to Set</h3> <div id="originalArray"></div> <div id="convertedArray"></div> </body> </html>