I am working on a javascript app which displays images of the results of different US elections. I am thinking there must be a quicker way to do this than what I am doing. There must be some way I can have one function that displays an election map with the year as a parameter, but how can I do this with image variables? I am trying to think of a quicker way to write this code. If anyone knows, please help me out.
<script>
var el2020img = "<img src=270towin.png width=600 height=300>";
var el2016img = "<img src=201019164452-2016-election-map.jpg width=600 height=300>";
function the2020election(){
document.getElementById("demo").innerHTML=el2020img;
}
function the2016election(){
document.getElementById("demo").innerHTML=el2016img;
}
</script>
I am wondering about how to do this.