Im learning Javascript, HTML and CSS and for do some practice i decided to do a website that choose a word randomly from input boxes.
When I do the console.log the array is empty and obviously items.length does not works.
Tysm if u can help me and fix my code.
JS
function randomword() {
  var words = [document.getElementById("word1"), document.getElementById("word2"), document.getElementById("word3"), document.getElementById("word4")]
  console.log(words)
  var items = words[Math.floor(Math.random() * items.length)];
document.getElementById("wresult").innerHTML = items
HTML
<div id=wgen>
            <label for="name">Prima parola (obbligatoria):</label>
            <input type="text" id="word1" name="name" required
                minlength="1" maxlength="40" size="40">
            <label for="name">Seconda parola (obbligatoria):</label>
            <input type="text" id="word2" name="name" required
                    minlength="1" maxlength="40" size="40">                
            <label for="name">Terza parola</label>
            <input type="text" id="word3" name="name" required
                    minlength="1" maxlength="40" size="40">
            <label for="name">Quarta parola</label>
            <input type="text" id="word4" name="name" required
                     minlength="1" maxlength="40" size="40">  
            <button onclick="randomword()" id='randomword' type="button">Genera</button>
            <p id=wresult></p>                           
        </div>
 
     
     
    