JavaScript JavaScript and the DOM Getting a Handle on the DOM Selecting Multiple Elements

Whta is wrong with my code?

The interpreter takes too long, and gets an error. It does not tell me if it is right or wrong. though I feel as if this code should work. can someone confirm to me or explain alittle? this is my second time going through this course and I feel as if I am still missing something?

<!DOCTYPE html>
    <ul id="rainbow">
      <li>This should be red</li>
      <li>This should be orange</li>
      <li>This should be yellow</li>
      <li>This should be green</li>
      <li>This should be blue</li>
      <li>This should be indigo</li>
      <li>This should be violet</li>
    <script src="js/app.js"></script>
let listItems = document.getElementsById('rainbow')[0].getElementsByTagName('li');
const colors = ["#C2272D", "#F8931F", "#FFFF01", "#009245", "#0193D9", "#0C04ED", "#612F90"];

for(var i = 0; i < colors.length; i ++) {
  listItems[i].style.color = colors[i];    

1 Answer

Gabriel Pierce-Lackey
Gabriel Pierce-Lackey
Treehouse Moderator 10,993 Points

I believe this is a current issue with challenges right now. Not something wrong with your code.