// loop through all properties on the slots object
for (var i in b.request.type.slots) {
if (b.request.type.slots.hasOwnProperty(i)) { // make sure it is a property belonging directly to slots, and not "inherited" from the prototype chain
if (b.request.type.slots[i].value) { // make sure that the sub-property of slots has a value property
document.getElementById("output").innerHTML = b.request.type.slots[i].value;
break; // break out of the loop after getting a value
}
}
}

Here I loop through all the properties on slots, checking that the property does indeed belong to slots, and that it has value property.