how to create new user based on input values

I have a problem and it’s hard, too hard for me as a beginner. Can you please help me. I know this is kinda strange creating this with javascript but it’s just my own project, nothing i will put on web. But i need this problem solved by using pure Vanilla Javascript, i have
users as shown below on .js and i have a page where i need to create i new user that can be logged in as same as other two(admin and guest), i need another guest user and created based on input values…Thanks in advance, i am still learning and comments would be appreciated as well..

var el = document.getElementById("login");
if (el) {
  el.addEventListener('click', state);
}

function state() {
  var username = document.getElementById("username").value;
  var password = document.getElementById("password").value;

  if (username == "admin" && password == "admin") {
    sessionStorage.setItem("isAdmin", "yes");
    alert("You are logged in as ADMIN !");
    window.location.href = "../index.html";
  } else if (username == "guest" && password == "guest") {
    sessionStorage.setItem("isAdmin", "no");
    alert("You are logged in as GUEST !");
    window.location.href = "../index.html";
  } else {
    alert("Incorrect username or password, try again !")
  }
}
<header>
  <div class="container">
    <div id="branding">
      <h1><span id="logo">mov</span>BLANK</h1>
    </div>
    <nav>
      <ul>
        <li><a href="../index.html">Home</a></li>
        <li><a id="newprojection" href="newprojection.html">New projection</a></li>
        <li><a id="buyticket" href="buyticket.html">Buy a ticket</a></li>
        <li class="current"><a id="newuser" href="newuser.html">New user</a></li>
        <li><a id="loginbtn" href="login.html">Log in</a></li>
        <li>
          <a id="nameofuser" href="#"></a>
        </li>
      </ul>
    </nav>
  </div>
</header>

<div class="container">
  <form>
    <p>Username</p>
    <input type="text" name="username" required>
    <p>Password</p>
    <input type="password" name="password" required>
    <p>Repeat Password</p>
    <input type="password" name="password" required>
    <p>Function(admin/guest)</p>
    <input type="text" name="function" required>
    <a id="adduser" href="#">Add User</a>
  </form>
</div>

how to create new user based on input values