JSFiddle - React, Tailwind, and code Playground
by zlojnaxa
HTML
<input class="choice" placeholder='Сюда введите "желтый"'>
<input class="choice" placeholder='Сюда введите "синий"'>
<input disabled id="result">
JavaScript
let choice = document.querySelectorAll('.choice'), time;
const array = [
{
0 : 'Желтый',
1 : 'Синий',
2 : 'Зеленый'
}
];
[...choice].forEach(e => {
e.addEventListener('keyup',()=> {
if(choice[0].value.toLowerCase() == array[0][0].toLowerCase() && choice[1].value.toLowerCase() == array[0][1].toLowerCase() ){
result.value = array[0][2];
}
else{
result.value = 'Ошибка...';
}
},false);
});