JSFiddle - React, Tailwind, and code Playground

HTML

<div class="views-field-field-section">
 Lifestyle
</div>

<div class="views-field-field-section">
 Politics
</div>

<div class="views-field-field-section">
 Economy
</div>

<div class="views-field-field-section">
 Local
</div>

<div class="views-field-field-section">
 Sports
</div>

<div class="views-field-field-section">
 News
</div>

CSS

.views-field-field-section{
    background-color: red;
    height: 100px;
    width: 200px;
}

JavaScript

var colorInput = document.getElementsByClassName('views-field-field-section');
for(i=0; i<colorInput.length; i++) {
          var colorInputText = colorInput[i].textContent.trim();
          switch (colorInputText) {
            case 'Lifestyle':
                    colorInput[i].style.backgroundColor = '#9518b8';                
                    break;
            case 'Local':
                    colorInput[i].style.backgroundColor = '#009fe3';
                    break;
            case 'Sports':
                    colorInput[i].style.backgroundColor = '#95c11f';
                    break;
            case 'Economy':
                    colorInput[i].style.backgroundColor = '#d40d10';
                    break;
            case 'Politics':
                    colorInput[i].style.backgroundColor = '#ffcc00';
                    break;
            default:
                    text ='Nix!'; 
      }
}