JSFiddle - React, Tailwind, and code Playground
HTML
<div id="one">
</div>
<section class="two">
</section>
JavaScript
! function() {
var addTextNode = (ele, text) => {
document.querySelector(`${ele}`).appendChild(document.createTextNode(`${text}`));
}
addTextNode("body", "This is ");
addTextNode("body","an example ");
addTextNode("body","of appending text ");
addTextNode("body","with an arrow function ");
addTextNode("body","and text nodes!");
//you can use this function to append to other things too!
//like an element with an id:
addTextNode("#one","appended to div with id='one' !");
//or an element with a class:
addTextNode(".two","appendedto section with class='two' !");
}();