This is my implementation when I was refreshing my basic skills through the https://github.com/bradtraversy/50projects50days/ repository.
There are many different ways to implement this. I encourage you to implement on your own using your methods or using the code as a starter logic for your implementation. It’s not good to memorize the code as you cannot visualize how you write your code. I even turn off Github Copilot, which although is useful in certain situations hinders my visualization of coding things.
If you found any errors, please comment below so I can improvise the code. I would also love to see your implementations through email or comments.
At the time of posting, these solutions are fine to implement but I would suggest to keep looking for newer and easier methods through MDN or new Youtube tutorials and new StackOverflow answers as these could become obsolete anytime in the future.