test1

by zxzc0

HTML

<div id="container">
  <div id="word"></div>

  <input type="text" placeholder="Inf" id="InputInf">
  <input type="text" placeholder="Sim" id="InputSim">
  <input type="text" placeholder="Par" id="InputPar">

  <input type="submit" value="Confirm" id="submit">
  <div id="test"></div>
</div>

CSS

body {
  background-color: #20262E;
  color: white;
}

#container {
  width: 700px;
  margin-right: auto;
  margin-left: auto;
}

JavaScript

const foo = () => {
var words = [
{INF: 'awake',	SIM: 'awoke',	PAR: 'awoken',	PL: 'obudzić',	},
{INF: 'be',	SIM: 'was',	PAR: 'been',	PL: 'być',	},
{INF: 'become',	SIM: 'became',	PAR: 'become',	PL: 'stawać się'},
{INF: 'begin',	SIM: 'began',	PAR: 'begun',	PL: 'zaczynać'},
{INF: 'bite',	SIM: 'bit',	PAR: 'bitten',	PL: 'gryźć'},
{INF: 'blow',	SIM: 'blew',	PAR: 'blown',	PL: 'dmuchać'},
{INF: 'break',	SIM: 'broke',	PAR: 'broken',	PL: 'łamać'},
{INF: 'bring',	SIM: 'brought',	PAR: 'brought',	PL: 'przynosić'},
{INF: 'build',	SIM: 'built',	PAR: 'built',	PL: 'budować'},
{INF: 'burn',  SIM: 'burnt',	PAR: 'burnt',	PL: 'płonąć'},
{INF: 'buy',  SIM: 'bought',	PAR: 'bought',	PL: 'kupować'},
]
  
  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() * 10);
  const postWord = () => { randomWord = word.innerText = words[num()].PL; } 

  postWord();
  
  submit.addEventListener('click', () => {
    const inputValueInf = document.getElementById('InputInf').value;
    const inputValueSim = document.getElementById('InputSim').value;
    const inputValuePar = document.getElementById('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 = '';
        test.innerText = '';
    }
    
    else if (inputValueInf != matchingInf || inputValueSim != matchingSim ||
    inputValuePar...