how to refresh the html elements with javascript without adding the element repeatedly

I have this code

<input type="button" value="refresh" onclick="refresh()">

<div id="parent-id">
</div>

<script>
function refresh(){
 let h1 = document.createElemet("h1")
 h1.textContent = "Testing..."
 document.querySelector("#parent-id").appendChild(h1);
}
</script>

each time I click on refresh the a new h1 will be added
How can I refresh, without adding a new h1?
I have not only this element, I have a big code of 200 lines but with the same idea.
How can I refresh them without adding them again to the page ?