So I have this text
" This is Sam.
Sam is my friend.
Sam is ten years old.
Sam likes football."
You can see Sam is repeated so many times. I want to assign it to a variable so that when I need to I can change the character name. Here is how I write it
var name = "sam"
document.getElementsByClassName("name").innerText= name;
<p> This is <span class="name"></span>.</p>
<p> <span class="name"></span> is my friend</p>
<p> <span class="name"></span> is ten years old.</p>
<p> <span class="name"></span> likes football.</p>
Please help me.
Thank you.