Assigning listingType
variable based on the conditions, you can use the equality operator (===
) for comparison and update the variable accordingly. Here's how you can do it:
const { intent } = TestBuddyData.output.detect;
const occupancyType = TestBuddyData.output.detect.entities.occupancy_type;
let listingType = '';
if (occupancyType.is_buy) {
listingType = 'sale';
} else if (occupancyType.is_rent) {
listingType = 'rent';
}
if (intent.is_property_scouting_score > 7 && listingType) {
const response = TestBuddyData.output.response.content;
const newAnswers = [...buddyA, response];
console.log(listingType);
setBuddyAs(newAnswers);
setCookie('buddy_a', newAnswers, { path: '/' });
} else {
// Handle other cases if needed
}