I need to create an array from all planet text:
<div class='planet'>earth</div>
<div class='planet'>sun</div>
<div class='planet'>moon</div>
var planets = JSON.stringify(Array.from($('.planet').text()));
console.log(planets);
In console I need:
["earth","sun","moon"]
Any help?
console.log(Array.from(document.querySelectorAll(".planet"), ({textContent}) => textContent));— without jQuery?Array.fromsupported a mapping function