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.