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

246
Vistas
Trouble using a prompt with object literal (JS)(New to coding)

I'm new to coding and JS so I'm sorry if this is a dumb question. I have an object literal named listA, which has various keys:values in it. I am trying to have the code prompt to the user all of the items (keys:values) in the object literal, and allow the user to input a response, which would get stored in another variable.

First off, I have the object literal to start off with:

var listA = {
"Pizza" : 15,
"Salad" : 5,
"Fries" : 6,
"Soda" : 2
};

I've tried many things all along the lines of:

var choice = prompt("What do you want?  \n" + listA);

This was in hopes it would prompt the user all of the items ("Pizza" : 15, "Salad" : 5,"Fries" : 6,"Soda" : 2,) and the user would input a response.

The exact problem is that whenever the code goes to prompt, it prompts [object] instead of all of the items inside the object literal (\\ the menu items) enter image description here

(\\the image above is what exactly it is currently prompting to the user, which is the problem I'm trying to fix)

*Sorry if I didn't ask the question great and/or didn't use stack overflow correctly, I'm new to coding (JS), and stack overflow

about 4 years ago · Juan Pablo Isaza
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