Add toggle button for mobile sub-menus

Been playing with this for hours but not getting anywhere, please help!

So I have a menu which works fine for the sub menu dropdown on desktop.

What I want for mobile menus is for their to be an icon, next to all li that have .menu-item-has-children. Then when the icon is clicked it changes to adds a class of ‘active’ to the sub-menu. When click again, the active class to be removed and the icon to return back to

The html is

The JS for it so far is

Any help is massively appreciated here