JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE HTML>
<html>
    
    <head>
        <script>
            var fav = new Array();

            function set() {
                var store = document.getElementById("txtUsername").value;
                localStorage.setItem('text', store);
                document.getElementById("show").innerHTML = "Item Stored!";
            }

            function show() {
                var newStore = localStorage.getItem('text');
                fav.push(newStore);
                document.getElementById("show").innerHTML = fav;
            }
        </script>
    </head>
    
    <body align="center">
         <h2>Data and LocalStorage</h2>
store:
        <input type="text" id="txtUsername">
        <br>
        <button type="button" onclick="set()">set</button>
        <button type="button" onclick="show()">show</button>
        <div id="show"></div>
    </body>

</html>