Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
Compare two array with same fields => if value is different highlight in html table

I have two set of array as response from an API, For example the server response is

let original= [ {firstVal:'1.2'},{SecondVal:'3.2'}];

let latest= [{firstVal:'1.2'},{SecondVal:'4.2'}]

the table will display value from latest array and logic is different value should be highlighted in bold

| Col1 | Col2 |
| 1.2 | 4.2 |

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Let's say you're rendering a table. I'm assuming that's how visualizing this data would make sense.

Then you'll store your first response and store it as its and render the default table

Now when you get your latest response. You'll start comparing row and then column wise if there is difference then the rendered value should be surrounded with a tag to make it bold. Here's a rough code

Assuming a react app


function RenderRow({row, index, latest}){
  if(latest.length < index) {
     console.log("This should not be possible")
     return null
  }

  return <tr>
  {
    row.map((column, c_index) => {
      if(latest[index][c_index] === column){
         return <td>{column}</td>
      }
      return <td><b> {column} </b></td>
    })
  }
  </tr>
}


function TableBody({original, latest}) {

  return <tbody>
   {
      original.map((row, index) => 
         <RenderRow row={row} index={index} latest={latest}/>
      )
   }
  </tbody>
}

function RenderAll(){
  let original= [ {firstVal:'1.2'},{SecondVal:'3.2'}];

  let latest= [{firstVal:'1.2'},{SecondVal:'4.2'}]
  return <Table latest={latest} original={original}/>
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda