Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript Change color based on a keys value in each object of array

function buildProjectsGrid(data) {
    let lastName = data[0]?.Name;
    let rowState = false;
    return data.map((obj) => {
      if (lastName !== obj.Name) {
        rowState = !rowState;
        lastName = obj.Name;
      }
      const colorClass = rowState ? 'red' : 'blue';
      ...
 
PREVIOUS NEXT
Tagged: #javascript #Change #color #based #keys #object #array
ADD COMMENT
Topic
Name
7+6 =