Question: I am working on the below demo. How can I add an event listener and handler to a `#checker` button to check the checkbox with the value of `Benz` using core JavaScript?

```js
function checkBenz(){

}

var el = document.getElementById("checker");
el.addEventListener("click", checkBenz);
```

```html
<button id="checker">Check Benz</button> <br />
<input type="checkbox" name="cars" value="Benz"> Benz <br />
<input type="checkbox" name="cars" value="BMW"> BMW <br />
```

Answer: 
Here's a generic way to handle your checking/un-checking of your checkboxes. Given a value for the checkbox you have, and the state you want to put it in - you can alter the checkboxes

```
function checkByName(value, check) {
    // given a checkbox value, check/un-check it
    var cbs = document.querySelectorAll('[value='+value+']')

    cbs.forEach(function(elem, ind) {
      elem.checked = check
    })
  }

```

And now you can trigger this using the click event on the button like

```
var btn = document.getElementById('checker')
btn.addEventListener('click', function() {
  checkByName('Benz', true)
})

```
I hope this helps 

```js
function checkBenz(){
    document.querySelector(`input[value="Benz"]`).setAttribute("checked", "true");
}

var el = document.getElementById("checker");
el.addEventListener("click", checkBenz);
```

```html
<button id="checker">Check Benz</button> <br />
<input type="checkbox" name="cars" value="Benz"> Benz <br />
<input type="checkbox" name="cars" value="BMW"> BMW <br />
```