Henry128 Henry128 - 4 months ago
318 0

Help, can't get this to work.

Javascript

help!?!?

Embed
<html> 
<body> 
<script>


var textIndex =0;
var lightIndex =0; 
var timer: 
var trafficLight = document.getElement ById('light'); 

var lights = [ 
     { 
      duration: 5, 
      color: 'Red', 
      image 'Red.jpg' 
 }, 
 { 
      duration: 5, 
      color: 'Amber', 
      image: 'Amber.jpg' 
 }, 
 { 
      duration: 5., 
      color: 'Green', 
      image: 'Green.jpg' 
  } 
] 

function advanceTrafficLightTimer() { 
           timerIndex++; 
    if(timeIndex == lights[ light].duration) { 
           timeIndex = 0; 
           lightIndex = lightIndex < lights.length - 1 ? lightIndex = lightIndex + 1 : 0;  
	   trafficLight.src = lights[lightIdex].image; 
          trafficLight.className = lights[LightIndex].color;
    } 
} 

timer = setInterval(advanceTrafficLightTimer,1000); 

</script> 
</body> 
</html>
Comments