<form >
<input data-input="1">
<input data-input="2">
<input data-input="3">
</form>
const inputs = document.querySelectorAll('input')
const state = {
input1: null,
input2: null,
input3: null,
}
inputs.forEach(item => {
item.addEventListener('input', function(e) {
state[`input${this.dataset.input}`] = e.target.value
})
})