JSFiddle - React, Tailwind, and code Playground

by Michael Keller

HTML

<div id="box"></div>
<div id="text"></div>

CSS

#box{
   width:50px;
   height:50px;
   background-color:orange;   
}

JavaScript

function findColor(value){
      var group = Math.floor(value/100);
    
      var color_array = ['lightblue', 'blue','darkblue'];
    
      $('#text').html(group + ' ' + color_array[group])
      return color_array[group];
     
}


var box_color = findColor(250);

$('#box').css('background-color',box_color);