I have this piece of code:
if (service.isHostel) {
return new Hostel({url: service.url});
} else {
return new booking({url: service.url});
}
that I want to express in 1 line,
service.isHostel ? Hostel({url: service.url}) : return new booking({url: service.url})
but I have a compilation error:
Expression expected.
return service.isHostel ? new Hostel({url: service.url}) : new booking({url: service.url})newkey word near the hostel object ?return service.isHostel ? new Hostel({ url: service.url }) : new booking({ url: service.url });