My goal is to dynamically change background images based on a URL parameter, specifically the destination code. With numerous background images available, it's crucial to display the correct one depending on the URL string. For instance, if the URL reads:
a corresponding background image should be linked to the 'ord' query.
Given the variety of station codes ('ord', 'lax', etc.) and corresponding images named 'dest-a', 'dest-b', and beyond, I aim to develop a function that automates the process of displaying the appropriate image based on the station code provided.
While my current script utilizes an if/else statement for this purpose, I'm seeking a more efficient approach to avoid manually assigning each station code with its respective background image within the 'bgImgs' object. How can I design a function that effortlessly swaps background images in alignment with the station code extracted from the URL query?