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 7441035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:56:47+00:00 2026-05-29T10:56:47+00:00

i have a varable: var name = name; this will be inside an array

  • 0

i have a varable:

var name = "name";

this will be inside an array of objects i have:

    var all = [];
    $.each(results, function(i, item){
        all.push({
            rank: i + 1,
            username: item.TopicName,
            mentions: item.LastHourCount,
            totalcount: item.TotalCount,
            urlLg: item.LargeImageUrl,
            urlSm: item.SmallImageUrl,
            shortname: item.ShortName
        });

    });

I need to look through the array of objects and find the ‘shortname’ that matches the variable ‘name’. the objects look like this:

Object[
  mentions: 21737
  rank: 2
  shortname: "name"
  totalcount: 59330
  urlLg: null
  urlSm: "http://i.cdn.turner.com/nba/nba/pulse/allstar/2012/img/images-small/howard.png"
  username: "lebron james"
],

once i find it set that to a variable:
var showThis = all.[];

Inside the each function as it loops through the json file, is probably where to look for the name?

  • 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-29T10:56:48+00:00Added an answer on May 29, 2026 at 10:56 am

    I think I may be misunderstanding. If you just want to find the entry in all with a shortName matching name, then:

    var match;
    $.each(all, function() {
        if (this.shortName === name) {
            match = this;
            return false;
        }
    });
    

    That uses $.each to loop through the array. In the iterator callback, this will refer to the array element, so we just check this.shortName === name. The return false stops the each loop. If there’s no match, match will keep its default value (undefined).

    Or as a traditional for loop:

    var match, index, entry;
    for (index = 0; index < all.length; ++index) {
        entry = all[index];
        if (entry.shortName === name) {
            match = entry;
            break;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an website with URL`s like example.com/index.php?p=home An this script $(document).ready(function() { var
I have a list of strings.. each one looks similar to this: \n\t\BLOCK\,\HEADER-\\r\n\t\t\NAME\,\147430\\r\n\t\t\REVISION\,\0000\\r\n\t\t\DATE\,\11/11/10\\r\n\t\t\TIME\,\10:03:47\\r\n\t\t\PMABAR\,\\\r\n\t\t\COMMENT\,\\\r\n\t\t\PTPNAME\,\0805C\\r\n\t\t\CMPNAME\,\0805C\\r\n\t\BLOCK\,\PRTIDDT-\\r\n\t\t\PMAPP\,1\r\n\t\t\PMADC\,0\r\n\t\t\ComponentQty\,4\r\n\t\BLOCK\,\PRTFORM-\\r\n\t\t\....(more).... What
I have the following variable that accepts a file name: var xtr = new
I have a code similar to this: $.ajax({ success: function(data) { text = '';
I have a nested Javascript object like var data = { 'name': { 'heading':
I want to create a quick function that will console.log a variable name and
i am new to JS objects. I have such code var foo = {
I have one template function which will take a pointer type and i have
i have one count down timer using http://keith-wood.name/countdown.html var austDay = new Date(); austDay
I have this code var myObjects = {}; //global variable //Later on in the

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.