Seperate Javascript for mobile devices


I’m currently working on my photo and video portfolio. With the help of ChatGPT and the internet I have created a javascript that plays a video when the thumbnail is hovered, which works fine on desktop. The if statement should disable this functionality on mobile and instead autoplay the video. However, this does not work. A quick check via the console showed that the script did detect it was a mobile device, but it doesn’t seem to apply the correct lines of code. Does anyone know how I can solve this?

Thanks in advance!

Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Hi Ruben, can you share a published site link to the page that you’re having the problem on?

Ruben vP Media (