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 AJAX Basics (retiring) Programming AJAX Stage 2 Challenge

Tristan Terry
Tristan Terry
9,044 Points

Everything is working except my code is all showing up as false, what am I missing?

var xhrRoom = new XMLHttpRequest();
xhrRoom.onreadystatechange = function () {
  if(xhrRoom.readyState === 4 && xhrRoom.status === 200) {
    var rooms = JSON.parse(xhrRoom.responseText);
    var statusHTML2 = '<ul class="rooms">';
    for (var j=0; j<rooms.length; j += 1) {
      if (rooms[j].avaliable === true) {
        statusHTML2 += '<li class="empty">';
      } else {
        statusHTML2 += '<li class="full">';
      }
      statusHTML2 += rooms[j].room;
      statusHTML2 += '</li>';
    }
    statusHTML2 += '</ul>';
    document.getElementById('roomList').innerHTML = statusHTML2;
  }
};
xhrRoom.open('GET', '../data/rooms.json');
xhrRoom.send();

So the styling seems to only be converting what is in my else statement.

Tristan Terry
Tristan Terry
9,044 Points

How about try spell check :P I mispelled available woot woot!

Rishit Shah
Rishit Shah
4,975 Points

you have misspelled the word "available". You have written if (rooms[j].avaliable === true) instead of if (rooms[j].available === true). Change it and your code should work fine. Please tell me if it still doesn't work.