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 trial

JavaScript One Solution

Nothing changes on the webpage

I have:

  • refreshed the page :P
  • looked for typos
  • seen the solution video

Still nothing is changing on the webpage...did I miss something?

My code: (Feel free to enlighten me how to share it in a more readable way..:))

// 1: Select the element with the ID 'about'. 
//    Store the element in the variable `about`.
const about = document.getElementById('about');
about.style.border = "2px solid firebrick";

// 2: Select all the <h2> elements in the document.
//    Set the color of the <h2> elements to a different color.
const h2 = document.getElementsByTagName('h2');
for (let i =0:i< h2.length; i += 1) {
  h2[i].style.color = 'dodgerblue';
}


// 3: Select all elements with the class '.card'. 
//    Set their background color to the color of your choice.
const card = document.getElementByClassName('card');
for (let i = 0; i < card.lengt; i +=1) {
  card[i].style.backgroundColor = 'orange';

}

// 4: Select only the first <ul> in the document.
//    Assign it to a variable named `ul`.
const ul = document.querySelector('ul');
ul.style.border = "2px solid indigo";

// 5: Select only the second element with the class '.container'.
//    Assign it to a variable named `container`.
const container = document.qetElementsByClassName('cointainer')[1];
container.style.backgroundColor = "royalblue";

// 6: Select all <a> elements that have a 'title' attribute. 
//    Set their color value to the color of your choice.

const title = document.querySelectorAll('a[title]');
for (let i =0: i < title.lengt; i += 1) {
  title[i].style.color = 'hotpink';
}

MOD: Edited question to format the code. :-)

Steven Parker
Steven Parker
231,261 Points

To preserve your code's layout, use Markdown formatting. There's a video on code formatting. Oherwise, it might look like certain things are wrong, but they are not in the actual code.

But even better is to make a snapshot of your workspace and post the link to it here. It allows your environment to be completely replicated to facilitate analysis of the issue.

3 Answers

You have a number of typos to fix. I'll just point them out and see if you can fix them. Using the console would be helpful.

2)

for (let i =0:

3)

getElementByClassName

i < card.lengt

5) (there are two)

qetElementsByClassName('cointainer')

6)(there are two)

for (let i =0: i < title.lengt
Steven Parker
Steven Parker
231,261 Points

Before you refresh your browser, be sure to save your edit changes with the menu or the Ctrl-S shortcut. If that's not it, try posting that snapshot link.

Steven Parker
Steven Parker
231,261 Points

Try starting a fresh question of your own where you can show your code (or better yet, make a snapshot of your workspace and post the link to it).