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 trialTristan Terry
9,044 PointsEverything 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.
Rishit Shah
4,975 Pointsyou 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.
Tristan Terry
9,044 PointsTristan Terry
9,044 PointsHow about try spell check :P I mispelled available woot woot!