var myImages = ["first.jpg", "second.jpg", "third.jpg", "fourth.jpg"];
var imgIndex = prompt("Enter a number from 0 to 3", "");
document.images[0].src = myImages[imgIndex];
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<img src="" width="200" height="150" alt="My Image">
<script src="main.js"</script>
</body>
</html>