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

140
Vistas
check if an object contains an object

I have an object values and I am looping through the object. If a property of the object startsWith('FLD_STR_') and if it has a an object as for value (like the FLD_STR_101), then return an object with its field, fileName, value, type.

here is the sample :

const values ={
  ID:748817,
  CODE:"OFFLINE-003",
  FLD_STR_101:{ field:"FLD_STR_101",
  fileName:"doc.pdf", value:'base64', type:"application/pdf"},
  FLD_STR_102:"coucou",
  Table:109414,
  OWNER:"MJACQUIER",

}


const test = for (const key in values) {
  if(key.startsWith('FLD_STR_') && its value is an object ){
  return {
    field: 'FLD_STR_101',
    fileName: key.fileName,
    value: key.value,
    type: key.type
   } 
  }
 }

console.log(test)

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I changed your code slightly, is that what you meant?

const values = {
  ID: 748817,
  CODE: "OFFLINE-003",
  FLD_STR_101: {
    field: "FLD_STR_101",
    fileName: "doc.pdf",
    value: 'base64',
    type: "application/pdf"
  },
  FLD_STR_102: "coucou",
  Table: 109414,
  OWNER: "MJACQUIER",

}


const test = function() {
  for (const key in values) {
    if (key.startsWith('FLD_STR_') && typeof values[key] === 'object') {
      return {
        field: key,
        fileName: values[key].fileName,
        value: values[key].value,
        type: values[key].type
      }
    }
  }
}
console.log(test())

about 4 years ago · Santiago Trujillo 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