Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda