Proponuję poczytać najpierw o podstawach JS - gotowiec na jakim możesz się wzorować:
<input id="input"/>
<p id="result"></p>
const result = document.getElementById('result');
document.getElementById('input')
.addEventListener('input', e => result.textContent = e.target.value);
tego ifa to dopisz sobie już jak chcesz.