Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialIvan 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!