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

  • Home
  • SEARCH
  • 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 7891769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:42:06+00:00 2026-06-03T06:42:06+00:00

I have a real time feed of names entering a JS function and I

  • 0

I have a real time feed of names entering a JS function and I would like to create an object such as:

var renderObj= {
{"name": "test1", "size": 3938},
{"name": "test2", "size": 3812},
{"name": "test3", "size": 6714}
};

So renderObj is empty to start. Each time a name comes in, I need to check if it exists in the object. If it does, update the size.

Can anyone advise?

  • 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-06-03T06:42:08+00:00Added an answer on June 3, 2026 at 6:42 am

    You can’t have unnamed items in an object. Use an array instead:

    var renderObj = [
      {"name": "test1", "size": 3938},
      {"name": "test2", "size": 3812},
      {"name": "test3", "size": 6714}
    ];
    

    Loop through the array to check if a name exists:

    var index = -1;
    for (var i = 0; i < renderObj.Length; i++) {
      if (renderObj[i].name == name) {
        index = i;
        break;
      }
    }
    

    Now check the result. I assume that you want to add an object if the name doesn’t exist yet. You didn’t say how you wanted the size updated, so I assumed that you wanted to add the new value to the previous:

    if (index == -1) {
      renderObj.push({ name: name, size: size });
    } else {
      renderObj[index].size += size;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Idea: I want to make smth like real time electronic blackboard. Many users have
I have a currently running PHP application that I want to add real-time feed
I would like to hear from people who have real world programming experience in
I'm writing an application in which I'd like to have near real time collaborative
Does anyone know how sites that have a real-time feed of a lot of
I am trying to develop a real-time feed, and have run into a dilemma.
So I have real time video stream. With 1 (one) person on It .
Can any one tell me an opensource js library that can have a real-time
I have a program that receives real time data on 1000 topics. It receives
I have a client interested in a real time chat application for a SharePoint

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.