I have function which randomly selects values from arrayVariable
and assingn them to paragraph element p[i].
I want to copy the randomly selected values to another array b[i].
How do i do it?
function rvalue() { var arrayVariable = ['1', '2', '3', '4', '5'] arrayLength = arrayVariable.length; ptags = document.getElementsByName("values"); for (i = 0; i < ptags.length; i++) { ptags[i].innerHTML = arrayVariable[Math.floor(Math.random() * arrayLength)]; } }
p { font-size: 2xpx; color: #000000; }
<body onload="rvalue()"> <p name="values"></p> </div> <p name="values"></p> </div> <p name="values"></p> </div> </div>