-3
I have a phrase the following random phrase: Pineapple, pear, apple and wanted in the variable var str = pick up my random phrase
<div class="page-header"><h1>Abacaxi, pera, maçã</h1></div>
<button onclick="myFunction()">botão</button>
<p id="demo"></p>
<script>
function myFunction() {
var str = "";
var res = str.split(" ");
var palavras = str.split(' ');
var reordenado2 = [palavras.pop()].join(' ');
document.getElementById("demo").innerHTML = reordenado2;
}
</script>