Using JS variables when filtering an array from EJS?

I want to filter my users array by “username” variable from js.

username = "arin2115";

var user = `<%-JSON.stringify(users.filter(x => x.username == "${username}")[0])%>`;

like something above, I have tried many ways to do it but any of them doesn’t work.
Thanks in advance.