color table rows Javascript

How to color table rows on the basis of column 'value' or 'text' in javascript
can i do it in script tag to check on each row if the cell value is A color the row as green if it B color it as red ...
should i do it in script after rendering the whole table or while rendering each row and how??

thanks