JavaScript JavaScript and the DOM Getting a Handle on the DOM Using CSS Queries to Select Page Elements

Ivan Boric
Ivan Boric
23,315 Points

Can't get text color to work

I'm using workspaces and Chrome Version 57.0.2987.98 (64-bit)

const myList = document.getElementsByTagName('li');

for (let i = 0; i < myList.lenght; i += 1) {
  myList[i].style.color = 'purple';

const errorNotPurple = document.querySelectorAll('.error-not-purple');

for (let i = 0; i < errorNotPurple.lenght; i += 1) {
  errorNotPurple[i].style.color = 'red';
<!DOCTYPE html>
    <title>JavaScript and the DOM</title>
    <link rel="stylesheet" href="css/style.css">
    <h1 id="myHeading">JavaScript and the DOM</h1>
    <p>Making a web page interactive</p>
<p>Things that are purple:</p>
  <li class="error-not-purple">oranges</li>
  <li class="error-not-purple">fire trucks</li>
  <li class="error-not-purple">snow</li>
    <script src="app.js"></script>
Ivan Boric
Ivan Boric
23,315 Points

Thx for the quick reply Alam...of course it had to be a typo :) works now, thanks!

1 Answer

You've spelt length wrong twice

See if that fixes it?

i < errorNotPurple.lenght; i += 1) {