Basic Tamagotchi

In this example, we define a Tamagotchi object with properties for its name, hunger, happiness, and energy levels, as well as methods for feeding, playing, and sleeping. We also define an updateStats method that updates the HTML elements on the page to display the current levels of each stat.

We then attach event listeners to the buttons for feeding, playing, and sleeping, which call the corresponding methods on the Tamagotchi object and update the stats displayed on the page.

You can customize this app further by adding more methods and properties to the Tamagotchi object, styling the HTML elements with CSS, and adding more interactivity with JavaScript.