Create a dropdown menu using HTML and JavaScript that redirects to a specific URL when an option is selected.


<select id="dropdown">
    <option value="">Select an option...</option>
    <option value="">Google</option>
    <option value="">Facebook</option>
    <option value="">Twitter</option>


// Get the dropdown element
var dropdown = document.getElementById("dropdown");

// Add event listener to redirect when option is selected
dropdown.addEventListener("change", function() {
  var selectedOption = dropdown.options[dropdown.selectedIndex].value;
  if (selectedOption !== "") {
    window.location.href = selectedOption;