alert box not working properly in JavaScript

<script>
    function fun(){
          let i=document.getElementById("input")
          if(i==="sam")
            {
               alert("welcome SAM")
            }
          else
            {
               alert("welcome user")
            }
        }
      </script>
     
        <input id="input"/>
        <button onclick="fun()">click</click>

if user type input as ‘sam’ it should be follow the if block but every time it execute else part .how to change the condition that when user type ‘sam’ in textbox then only it follow if block or else execute else part