
Ivan Boric
23,315 PointsCan'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>
<html>
<head>
<title>JavaScript and the DOM</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1 id="myHeading">JavaScript and the DOM</h1>
<p>Making a web page interactive</p>
<p>Things that are purple:</p>
<ul>
<li>grapes</li>
<li class="error-not-purple">oranges</li>
<li>amethyst</li>
<li>lavender</li>
<li class="error-not-purple">fire trucks</li>
<li class="error-not-purple">snow</li>
<li>plums</li>
</ul>
<script src="app.js"></script>
</body>
</html>
1 Answer

ruhullalam
14,500 PointsYou've spelt length wrong twice
See if that fixes it?
i < errorNotPurple.lenght; i += 1) {
Ivan Boric
23,315 PointsIvan Boric
23,315 PointsThx for the quick reply Alam...of course it had to be a typo :) works now, thanks!