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

249
Vistas
Check all the values of an object then if the values is empty it will return what is the key of that empty value?

I have an object store in useState, i just want to find out which of this keys have a value of empty and return the key of that emply value

const [projectInfo, setProjectInfo] = useState({
projectName: '',
projectDescription: '',
projectCreator: '',
})
const [error, setError] = useState({})

const handleCheckValidation = () => {
if(!projectInfo.projectName){
 setError((prevState) => ({
                            ...prevState,
                            projectNameError: true,
                          }))

Thanks!

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

0

you can filter the empty value, it will give you array item of empty value,

   const isEmptyValue = Object.keys(projectInfo).filter((item) => projectInfo[item] === '')
    
    output: ["projectName", "projectDescription", "projectCreator"]

or if the object is dynamic, and you are getting it through props or api

const [projectInfo, setProjectInfo] = useState(Object.keys(yourObject).filter((item) => yourObject[item] === ''))
about 4 years ago · Juan Pablo Isaza Denunciar

0

const object = {
  projectName: '',
  projectDescription: '',
  projectCreator: '',
}

const nullKeys = []

Object.keys(object).forEach(key => {
  if(!object[key]){
    nullKeys.push(key)
  }
})

console.log(nullKeys)
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