Q: use number increments to call array one at a time, not work with multiple attributes my javaScript intend to increment i each time button is clicked, and return a different result from the array. not sure why it only works partially.
<!DOCTYPE html>
<html>
<body>
<p id="demo">hi</p>
<img id="img" src="" alt="Pulpit rock" width="304" height="228"><br>
<button onclick="next()">next</button>

<script>
var myCars=["BMW","Toyota","Honda"];
var i=0;

function next() {
document.getElementById("demo").innerHTML=myCars[i]; //shows different text everytime
document.getElementById("img").alt=myCars[i]; //does not change everytime
i++;
}
</script>
</body>
</html>

