How to register scripts in wordpress

I am new to wordpress, I have a toggle nav that’s working just fine in html with this code.

however I don’t know the correct way to register it on wordpress functions.php to make my toggle nav work. and should I put it in a js folder, please help.