'How to do combination of returns in scope of other return statement in javascript nodejs

i have multiple queries listed, out of which individuals are executed hasslesly however combination of those isnt working in return statement, im new to this... plz help me where am i going wrong. I need req.params.sqft query to return its logic as well as other function logic with it(bedroom & washroom).

exports.getProp = (req, res) => {
  const bedRoom = propData.filter((data) => {
    return data.facilities.bedroom == req.query.bedroom;
  });
  const washRoom = propData.filter((data) => {
    return data.facilities.washroom == req.query.washroom;
  });
  
  
  if (req.query.sqft) {
  console.log("sqft input", req.query.sqft);
  const limit = req.query.sqft.toString().split(",");
  console.log("after split", limit);
  const details = propData.filter((item) => {
    if(req.query.bedroom!=0)
    { if ((item.sqft <= limit[1]  && item.sqft >= limit[0]) && bedRoom )
      {
        return (propData);
      }
    }
  });
   
    console.log(details)
    // return res.json(successResponse(true, 'Success' + req.query.bedroom.toString(), details));
    console.log(bedRoom)
    return res.json(successResponse(true, 'Success',details ));

  }

  if (req.query.bedroom) {
    return res.json(successResponse(bedRoom));
  }
  if (req.query.washroom) {
    return res.json(successResponse(washRoom));
  }
  return res.json(successResponse(propData));
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source