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

116
Vistas
JS alter JSON value to match key

I have the following JSON and I am trying to alter it to have the same key and value string:

var icons = {
      "123": 63103,
      "alarm-fill": 61697,
      "alarm": 61698
}

I'm trying the following code:

var newIcons = [];

for (var key in icons) {
    if (icons.hasOwnProperty(key)) {
        newIcons.key = key;
    }
}

console.log(newIcons);

It should return the following:

{
  "123": "123",
  "alarm-fill": "alarm-fill",
  "alarm": "alarm"
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

var newIcons = {};

for (var key in icons) {
    newIcons[key] = key;
}

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