title: How to set a color for a 'string' JavaScript
body: <p>I want to be able to set a color for a color name, so if a user inputs the string 'green' the color would be a special green like #34ff8b. </p>
  
  <p>I have already attempted using a variable and setting the color to the string 'green', but that is not valid js. </p>
  
  <p><strong>Desired Outcome:</strong> 
  User inputs a color name "green" and javascript uses a special color set in the js code. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const myButton = document.getElementById('myButton');
  const myHeading = document.getElementById('myHeading');
  const myTextInput = document.getElementById('myTextInput');
  
  
  myButton.addEventListener('click', () =&gt; {
    myHeading.style.color = myTextInput.value;
  } );</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>@import 'https://fonts.googleapis.com/css?family=Lato:400,700';
  
  body {
    color: #484848;
    font-family: 'Lato', sans-serif;
    padding: .45em 2.65em 3em;
    line-height: 1.5;
  }
  h1 {
    margin-bottom: 0;
  }
  h1 + p {
    font-size: 1.08em;
    color: #637a91;
    margin-top: .5em;
    margin-bottom: 2.65em;
    padding-bottom: 1.325em;
    border-bottom: 1px dotted;
  }
  ul {
    padding-left: 0;
    list-style: none;
  }
  li {
    padding: .45em .5em;
    margin-bottom: .35em;
    display: flex;
    align-items: center;
  }
  input,
  button {
    font-size: .85em;
    padding: .65em 1em;
    border-radius: .3em;
    outline: 0;
  }
  input {
    border: 1px solid #dcdcdc;
    margin-right: 1em;
  }
  div {
    margin-top: 2.8em;
    padding: 1.5em 0 .5em;
    border-top: 1px dotted #637a91;
  }
  p.description,
  p:nth-of-type(2) {
    font-weight: bold;
  }
  /* Buttons */
  button {
    color: white;
    background: #1ad777;
    border: solid 1px;
    border-color: rgba(0, 0, 0, .1);
    cursor: pointer;
  }
  button + button {
    margin-left: .5em;
  }
  p + button {
    background: #52bab3;
  }
  .list button + button {
    background: #768da3;
  }
  .list li button + button {
    background: #508abc;
  }
  li button:first-child {
    margin-left: auto;
    background: #52bab3;
  }
  .list li button:last-child {
    background: #768da3;
  }
  li button {
    font-size: .75em;
    padding: .5em .65em;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;JavaScript and the DOM&lt;/title&gt;
      &lt;link rel="stylesheet" href="css/style.css"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1 id="myHeading"&gt;JavaScript and the DOM&lt;/h1&gt;
      &lt;p&gt;Making a web page interactive&lt;/p&gt;
      &lt;input type="text" id="myTextInput"&gt;
      &lt;button id="myButton"&gt;change headline color&lt;/button&gt;
      &lt;script src="app.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>