I'm trying to implement multiple search functionality such as userName and userId with separate input for userName and userId. If I give userName as "Dave Steve" or "dave steve" or "Dave" or "steve" or "dav" and click on the search button I should get the result But When I give "Dave steve" it working fine but not with other case How do I implement it ?
Json data:
let logData={
"dataLog":
[
    {
        "userId":"1",
        "userName":"Dave Steve",
    },
    {
        "userId":"2",
        "userName":"John Doe",
    }
],
}
Here is my code
app.get('/getData', (req, res) => {
  let accessData= logData.dataLog;
  let userName = req.query.userName;
  let userId = req.query.userId;
    console.log(userName, userId)
    let filterData = accessData.filter((data) => {
      return (userId === undefined || data.userId === userId) &&
        (userName === undefined || userName === userNameData)
    })
    console.log(filterData)
    const response = {
      header: getSuccessHeader,
      body: filterData
    };
    res.status(200);
    res.send(response);
});
 
     
     
    