When a new dropdown option is selected, the screen is cleared of the previous dropdown image

Need to know how to clear the screen of a previous dropdown image, when a new dropdown option is selected and its related image shows…
Is the code here really the most efficient way of doing this?

If Statements and dropdowns

Greetings @appsforgood,

Based on the limited code snippet you’ve provided i assume you’d like the dropdown of the selected event swap between or clear a current image from your screen. I think your best option would be to put your image urls into an array and swap it that way rather than needing to update the images manually and may make it easier App Lab - Code.org

This section will also include the archived source code just in case the link is lost or abandoned

var icons = ["", "subway", "plane", "car"];
var options = getProperty("vehicle_dropdown", "options");
function setIcon(index) {
  var iconID = "icon_image";
  if (index > 0) {
    setImageURL(iconID, "icon://fa-" + icons[index])
  } else {
    setImageURL(iconID, icons[index]);
onEvent("vehicle_dropdown", "change", function () {
  var choice = options.indexOf(getText("vehicle_dropdown"));

perhaps this may help more toward your solution it uses an array with matching inputs along with outputs… this could have also been 1 array if you chose the same name as the icons but I wanted to keep all the elements without having to modify anything within them then by calculating what choice you chose it get sent to setIcon which then determines what image to display based on the output selected without needing to hide all the other images instead it uses setImageURL on a single element that handles all states that an icon can show

Best of luck!