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

281
Vistas
How to change object key value number to string value

I am working on a project; the object has a dynamic key and a dynamic value. I will find which number the keys are holding, and change the number to string value, assuming the object list is too big to check each individually- more than 30 key values

const obj =  {
    one: 'jkej',
    two: 123,
    three: 'abc'
  }

Required output is

const obj =  {
    one: 'jkej',
    two: '123',
    three: 'abc'
  }

I want to change the what are the keys holding, and change the number value to string.

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

0

You can loop the keys of the object and convert the values to string

Object.keys(obj).forEach((k) => {
  obj[k] = obj[k].toString()
})
about 4 years ago · Santiago Trujillo Denunciar

0

You can do something like this

const obj = {
  one: 'jkej',
  two: 123,
  three: 'abc'
}

const convertToString = (object) =>
  Object.fromEntries(
    Object.entries(object)
    .map(([k, v]) => [k, v + ''])
  )


console.log(convertToString(obj))

about 4 years ago · Santiago Trujillo Denunciar

0

You can iterate through the object and cast everything into a string using toString():

for (let [key, value] of Object.entries(myObject)) {
    value = value.toString()
}
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