title: Using function to change color based on Boolean value in another function in JS
body: <p>I have a function that returns something like this :</p>
  <pre><code>let checkAddedValuesFunction =
  </code></pre>
  <pre><code>{&quot;444&quot; =&gt; Array(1), &quot;T&quot; =&gt; Array(1), &quot;:778&quot; =&gt; Array(1)}
  
  0: {&quot;444&quot; =&gt; Array(1)}
  key: &quot;444&quot;
    value: Array(1)
    0: {isValue: true, string: &quot;111:222:444&quot;, at: 8}
  
  1: {&quot;T&quot; =&gt; Array(1)}
  key: &quot;T&quot;
   value: Array(1)
   0: {isValue: false, string: &quot;SQL_DT&quot;, at: 5}
  
  2: {&quot;:778&quot; =&gt; Array(1)}
  </code></pre>
  <p>I'm trying to create a function that will change color of the elements in the string based on isValue true/false statement. I'm currently doing something like this but it seems to be not working at all:</p>
  <pre><code>
      const changeColor = (target) =&gt; {
        for (const [key, value] of Object.entries(checkAddedValuesFunction)) {
  
          ~~// FIND IF VALUE IS TRUE THEN GO AND CHANGE COLOR //~~
  
          if (document.querySelector(&quot;.compareKey&quot;)) {
            document.querySelector(&quot;.compareKey&quot;).style.backgroundColor = &quot;red&quot;;
          } else if (document.getElementsByClassName(&quot;.compareValue&quot;)) {
            document.getElementsByClassName(&quot;.compareValue&quot;).style.backgroundColor =
              &quot;red&quot;;
          }
        }
  
      };
  </code></pre>