You can make a pet game with javascript, however, this wouldn’t be a full fledged browser based one.
In order to make a full fledged browser based one, you’ll need to code it in php/mysql.
This tutorial explains more in depth how you can make one with javascript:
There's a tutorial that provides tips and advice on how you can make one with unity with the use of C# as well:
If you'd like to take a deeper dive and learn how to make a browser based one, I'd recommend watching this tutorial on how to make one with php/mysql.
Siteground has some great guides and articles relating to php/mysql as well. I'd check out their articles as well. It's an awesome resource site.
Learn what PHP and MySQL are and read tutorials on some of the most commonly asked questions about PHP & MySQL
eu.siteground.com
Freecodecamp is also great. They have tons of guides and articles as well.
The PHP Handbook – Learn PHP for Beginners