JSFiddle - React, Tailwind, and code Playground

by zxzc0

HTML

<div id="quiz">
<div id="word">Zaczynać</div>

	<input type="text" id="InputInf" class="quiz-input" placeholder="Infinitive">
	<input type="text" id="InputSim" class="quiz-input" placeholder="Simple Past">
	<input type="text" id="InputPar" class="quiz-input" placeholder="Past Participle">

	<input type="submit" id="submit" class="submit" value="Check">

	<div class="ugh">
		<div id="answerInf" class="answer"></div>
		<div id="answerSim" class="answer"></div>
		<div id="answerPar" class="answer"></div>
	</div>

JavaScript

const foo = () => {

var words = [
{INF: 'be', 	SIM: ['was', 'were'],	PAR: 'been',	PL: 'być',	},
{INF: 'begin',	SIM: 'began',	PAR: 'begun',	PL: 'zaczynać'},
]

  const word = document.getElementById('word');
	const test = document.getElementById('test');
  const InputInf = document.getElementById('InputInf');
  const InputSim = document.getElementById('InputSim');
  const InputPar = document.getElementById('InputPar');
	const submit = document.getElementById('submit');

  let randomWord = null;

  const num = () => Math.floor(Math.random() * 2);
  const postWord = () => { randomWord = word.innerText = words[num()].PL; }

  postWord();

  submit.addEventListener('click', () => {
    const inputValueInf = InputInf.value;
    const inputValueSim = InputSim.value;
    const inputValuePar = InputPar.value;
    const matchingInf = words.find(word => word.PL === randomWord).INF;
    const matchingSim = words.find(word => word.PL === randomWord).SIM;
    const matchingPar = words.find(word => word.PL === randomWord).PAR;

    if (inputValueInf === matchingInf  && inputValueSim === matchingSim  &&
    inputValuePar === matchingPar) {
    	postWord();
      	InputInf.value = '';
    		InputSim.value = '';
    		InputPar.value = '';
        answerInf.innerText = '';
        answerSim.innerText = '';
        answerPar.innerText = '';
      return;
}

  if(inputValueInf !== matchingInf){
      answerInf.textContent = "[ "+matchingInf+" ]";
        document.getElementById("answerInf").className = "answer";
    }   else{
          document.getElementById("answerInf").className = "display-none";
    }

  if(inputValueSim !== matchingSim){
      answerSim.textContent = "[ "+matchingSim+" ]";
        document.getElementById("answerSim").className = "answer";
    }   else{
          document.getElementById("answerSim").className = "display-none";
    }

  if(inputValuePar !== matchingPar){
      answerPar.textContent = "[ "+matchingPar+" ]";
       ...