Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!