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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:46:16+00:00 2026-06-05T11:46:16+00:00

I have a JavaScript object like the following var items = { k1: value1,

  • 0

I have a JavaScript object like the following

 var items =
    {
        "k1": "value1",
        "k2": "value2",
        "k3": "value3"
    };

How can I compare key with a fixed number to get key and value of (“k2”, value2) ?
Example: k1 = 9, k2 = 15, k3 = 23; fixed number (fix=12)

I will loop through all items to get only my key and value:

function(fix) {
  for(var key in items) {
     if (fix > k1 || fix <= k2) {
        document.write( key + " : " + items[key] + "<br />");
     }
  }
}

How can I do that ?

  • 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-05T11:46:18+00:00Added an answer on June 5, 2026 at 11:46 am

    Use this code i hope it will help you.I just edit your code and get value

    <script type="text/javascript" language="javascript">
    
        var items =
    {
        "k1": 1,
        "k2": 2,
        "k3": 3,
        "k4": 4
    };
        function testnew(fix) {
    
            for (var key in items) {
                 if (parseInt(fix) >= parseInt(items[key]) && parseInt(fix) <= parseInt(items[key])) 
                 {
    
                     alert(items[key]);
                 }
             }
        }
    </script>
     </head>
     <body>
       <div id="divtest" onclick="testnew(3);">test</div>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JavaScript object like the following: var p = { "p1": "value1",
I have following resourceBundle Javascript object. var resourceBundle = { en : { MSG1
If I have a javascript object that looks like the following: { 0: [0,50],
I have a JavaScript object that looks something like this: var myTextOptions = {
I have an array of javascript objects like the following: var food = [
I have a object which i looked from firebug looks like following var object
I have a JavaScript object that looks like the following: venue = function(map, dataSet)
I have the following javascript object literal (excerpt) var foo = {hello[35]:100,goodbye[45]:42}; I have
I have created the following javascript object dynamically (from PHP): var t_feed = '';
I have an object like the following: var RevenueCodes = { 41020: Addendum, 41040:

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.