JSFiddle - React, Tailwind, and code Playground

by austinpray

HTML

<div id="p">
  <strong>well</strong> Hello<br/>
  World
  <br>
</div>

JavaScript

const a = document.getElementById('p');
console.log('innerHTML', a.innerHTML);
console.log('textContent', a.textContent);
console.log('strip newlines', a.textContent.split('\n').map(str => str.trim()).filter(str => !!str).join(' '));