I'm working on putting a simple slide show on the homepage of a website I'm building for my coding class. I have this simple code, but it's not working. Can anyone help me figure out why it's not working? I can't figure it out. I've went over the code over and over again and using the debugger in VS, but I can't seem to find anything wrong with it. Thanks.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>slide show</title>
<script>
var i=0;
var images =[];
var time = 2000;
images[0] ="pindex-1.jpg";
images[1] ="pindex-2.jpg";
images[2] ="pindex-3.jpg";
function changeImg() {
document.slide.src=images[i];
if (i < images.lenghth -1) {
i++;
} else {
i = 0;
}
setTimeout("changeImg()", time);
}
window.onload = changeImg;
</script>
</head>
<body>
<img name="slide" width="300" height="200">
</body>
</html>