JSFiddle - React, Tailwind, and code Playground

by ryan Couch

HTML

<div id="foo"></div>

JavaScript

var toolState = {
    draw_point: false,
    draw_line: false
};

var dynamicText = "draw_point";

var node1 = document.createElement("LI");
node1.appendChild(document.createTextNode(toolState.dynamicText));  //this doesn't work
console.log(toolState.dynamicText);                                 //this doesn't work
document.getElementById('foo').appendChild(node1);

var node2 = document.createElement("LI");
node2.appendChild(document.createTextNode(toolState[dynamicText])); //this does
console.log(toolState[dynamicText]);                                //this does
document.getElementById('foo').appendChild(node2);