Input name and store using localStorage in JS

I need help in localStorage in JS. I want a program that takes input from my website (of course not registered domain) and saves the input . My code of HTML is the following :

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body bgcolor="lightyellow">
    <CENTER>
        <h1>Registeration Form</h1>
    </CENTER>
    <hr>
    <h2>Username :</h2>
    <input type="text" id="name">
    <br>
    <h2>Password: </h2>
    <input type="password" id="pass">
    <br>
    <button type="button" id="btn">SUBMIT</button>
    <script src="e.js"></script>
</body>
</html>

I tried storing the value using JS but it didnt work.

document.getElementById("btn").addEventListener("click", function() {
name = document.getElementById("name").value;
pass = document.getElementById("pass").value;
localStorage.setItem(name , "name");
localStorage.setItem(pass , "pass");
console.log(localStorage.getItem(name));
console.log(localStorage.getItem(pass));
})

I was of course doing something wrong here.
PLs help me