how to set diferent images in html through js

JavaScript
<div id="x"></div>

<script>
var img = document.createElement("img");
 
img.src = "image.png";
var src = document.getElementById("x");
 
src.appendChild(img);
</script>var img = document.createElement('img');
Source

Also in JavaScript: