How to change text in a div if the screen is less than..?

```
<a href="#">View full profile</a>
if(screen <= 768) {
   <a href="#">View</a>
}

```

Sorry I'm new to Javascript. I've seen similar questions around but any of them has a correct answer.

I know I could use css to achieve this but I don't want to repeat the html code just to hide/show elements.