Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6356793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:02:15+00:00 2026-05-24T23:02:15+00:00

I have been messing around for a project I’m working on with arrays in

  • 0

I have been messing around for a project I’m working on with arrays in JS. However, since this didn’t work out, I had to turn to objects. Never having used these, I’m wondering about something fairly simple, yet complicated to me. I have the following code:

var ticket_amount = {};
var days = $(".t_days_" + ticket_id).val().split(',');

for(var i = 0; i < days.length; i++)
{
    if (! ticket_amount[days[i]]) 
    {
        ticket_amount[days[i]] = 0;
    };
        ticket_amount[days[i]] += num_tickets;
}

This gives me my output as follows:

object

I now want to use the information in this object to display some more information. More specifically, I need to get both the date and the ticketnumber out so I can work with them in jQuery. I’m not sure how to do this, though.

I’ve tried stuff like:

for(tickets in ticket_amount) { }, for(var i = 0; i < ticket_amount.length; i++) {}, but none of these options seem to work. How do I get the information out in this specific case? Thanks a lot.

I won’t be on the computer after posting this so I won’t be able to answer to any questions for now, but I will find time for it tomorrow. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:02:16+00:00Added an answer on May 24, 2026 at 11:02 pm

    You were almost correct. This would print the data you need, for example.

    for(ticket in ticket_amount)
    {
        console.log("Ticket:" + ticket + " amount: " + ticket_amount[ticket]);
    }
    

    EDIT:

    of course, ticket in the above example should have been named just a tad better 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am haveing some problems with JSON and arrays. I have been messing around
I have been messing around with iTunes COM from python. However, I haven't been
I have been messing around with HtmlUnit for a little bit and particularly this
I have been messing around with writing some stored procedures in .NET code with
I have been messing around with Leaks trying to find which function is not
I have been messing around with my meta descriptions, trying to make them more
I have been messing around with OpenGL lately, and I noticed that the windows
Have been working on this question for a couple hours and have come close
i have been messing around with a search engine and i am trying to
Hey all, I've been messing around with this awesome library on my *nix box,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.