Question: I have a list of users store in an array

```json
accountsade: [
    {
        id: 0.4387810413935975
        name: "Adrian"
        password: "345"
        userName: "nathanael"
    },
    {
        id: 0.2722524232951682
        name: "Nathan"
        password: "123"
        userName: "nathanaelmbale45"
    }
],

```

And I want to loop through the list of users and capture the values `password`, and `username`
of every single object in the array and compare them to already existing variables.

```
usernameL = "nathanaelmbale45"
passwordL = "123"

```

Answer: 
```
    <script>
    let accountsade = [
        {
            id: 0.4387810413935975,
            name: "Adrian",
            password: "345",
            userName: "nathanael",
        },
        {
            id: 0.2722524232951682,
            name: "Nathan",
            password: "123",
            userName: "nathanaelmbale45"
        }
    ]
    let userName = 'nathanael', password = '345';
    let account = accountsade.filter((item) => {
        return item.userName === userName && item.password == password;
    });
    console.log(account);
</script>

```

-----------# output #-----------------

```
[{"id":0.4387810413935975,"name":"Adrian","password":"345","userName":"nathanael"}]

```
As mentioned in comments, doing this in client side code would be a BAD idea because you expose all of your usernames and passwords to something that can be easily found in the browser console...

For the sake of understanding array functions though... this will return the first matching object in the array based on matching username and password.

```js
var accountsade = [
  {
    id: 0.4387810413935975,
    name: "Adrian",
    password: "345",
    userName: "nathanael"
  },
  {
    id: 0.2722524232951682,
    name: "Nathan",
    password: "123",
    userName: "nathanaelmbale45"
  }
];

var usernameL = "nathanaelmbale45";
var passwordL = "123";

///////////////////////////////////////////////////////////////////
// array.find takes as its arrgument a function that gets run
// against each element of the array
//
// array.find will return the current element being supplied
// the first time the provided function returns a "true" value
//
// if the provided function always returns a "false" value...
// then array.find will return the value "undefined"
///////////////////////////////////////////////////////////////////

var authUser = accountsade.find(function(element) {
  var returnValue = true;
  returnValue &= element.userName == usernameL;
  returnValue &= element.password == passwordL;
  return returnValue
});

console.log(authUser);
```