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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:09:53+00:00 2026-06-09T18:09:53+00:00

I am looping through a object, and conditionally i am consoling the result. but

  • 0

I am looping through a object, and conditionally i am consoling the result. but i am getting all the 3 result, instead to get just 2. what is wrong with my code?

Any suggestion please?

my code :

 var processModules = function (mData) {
    var lcalmData = obj = {'content':'new content','navigation':'newNavigation','form':'newform'}; var title;
    $('body').append(
        $.each(lcalmData, function (i,val) {
            title = (i === 'content' || i === 'navigation')  ? $('<div />') : i === 'form' ? $('<form />') : null;
            return title;
        } )  
    )
}

jsfiddle

  • 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-09T18:09:54+00:00Added an answer on June 9, 2026 at 6:09 pm

    This line is problematic:

    val === 'content' || 'navigation'

    I suppose you meant to check whether val is equal to one of these values? ) But it doesn’t work this way: as === operator priority is higher than || one, it’s essentially the same as…

    (val === 'content') || 'navigation'

    … in other words, always a truthy value.

    What you intended may be rewritten just as simple as…

    ... (i === 'content' || i === 'navigation')

    … as it’s the index (key) that should be checked, not value.

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

Sidebar

Related Questions

I'm looping through a large object where the internal properties are not all consistent.
I'm using KnockoutJS version 2.0.0 If I'm looping through all properties of an object,
I'm looping through an object in javascript and deleting an item that is undefined,
I'm using Node.js w/ node_redis and am looping through an object and looking up
I am looping through an NSString object called previouslyDefinedNSString and verifying if the integer
Say I'm looping through like 20/30 objects or in any other case where I'm
While looping through a Dataset which code snippet should I use, should I go
Must be a way looping through this code: private void loadSprites() { this.sprites[0] =
I'm looping through an array in JavaScript to check for null in each object
I am looping through table rows in a table, but the first 1 or

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.