assign color to a grid cell using a variable

I know how to assign the background-color to a grid cell as follows:
myGrid.setCellTextStyle(rId,1,“background-color:#D8D8D8;”);

However, I need to assign a specific color based on logic elsewhere in my js file. For example:

var tcolor;
if(a==1) tcolor="#D8D8D8";
else tcolor="#99FFFF";
myGrid.setCellTextStyle(rId,1,“background-color:tcolor;”);

Unfortunately, this only results in the requested color being ignored, giving me the default background color instead.

Is there a way to do this? Thanks

You may try to use:
myGrid.setCellTextStyle(rId,1,“background-color:”+tcolor+";");

Works great.
Thanks!