Все работает исправно, но задачу не принимает. Событие submit пробовал, тоже самое.
<form name="names">
<div class="input-wrapper">
<input type="text" id="firstName" name="firstName">
<label for="firstName">First name</label>
</div>
<div class="input-wrapper">
<input type="text" id="lastName" name="lastName">
<label for="lastName">Last name</label>
</div>
<div class="button">
<button name="btnSubmit">Generate greeting</button>
</div>
</form>
<script>
const form = document.forms.names;
form.btnSubmit.addEventListener('click',(e)=>{
e.preventDefault();
if(form.firstName.value && form.lastName.value){
console.log(`Hello, ${form.firstName.value} ${form.lastName.value}!`);
//form.reset();
form.firstName.value = '';
form.lastName.value = '';
}
})
</script>