replace multiple <p> with arrays

Viewed 53

first i was able to change
<p id="test">here what i want to replace</p>
to <p id="test">successfully replaced</p>
with

var txt1 = "successfully replaced"; document.getElementById('test').innerText = txt1;

and now i want to replace multiple <p> but with effective/shortway using arrays, like this

var txt1 [success1:"successfully replaced 1",
      success2:"successfully replaced 2",
      success3:"successfully replaced 3"];

but when i reload the browser i didn't see any changes on that <p>
i just started learning javascript last week so I'm still not sure about that

1 Answers
Related