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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:01:37+00:00 2026-06-14T21:01:37+00:00

It sounds weird but I need this for now.Actually I have an array like

  • 0

It sounds weird but I need this for now.Actually I have an array like that :

var arr = new Array(123, 432, 98, 227, 764);
var max = Math.max.apply(Math, arr); //calculate max = 764
var min = Math.min.apply(Math, arr); //calculate min = 123

Now I have to make several range based on the min and max:

 100 - 200 // as the min is 123 (range 100 ~ 200) 
 201 - 300
 301 - 400
 401 - 500
 501 - 600
 601 - 700
 701 - 800 // as the min is 764 (range 700 ~ 800)

Making the range is just a loop issue.But calculating the range of min and max I implemented as :

function integerRound (digit) {
    var i = 0, msb; 
    while( digit > 0 ) {
      msb = digit % 10;
      digit = Math.floor( digit / 10 );
      i++;
    }
    while ( i > 1 ) {
      msb = msb + '0';
      i--;
    };
    return msb;
}

var lowerMin = integerRound(min); // 100
var lowerMax = integerRound(max); // 700

My question is – Is there any good way to do that in javascript or jQuery?

  • 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-14T21:01:39+00:00Added an answer on June 14, 2026 at 9:01 pm

    Given this use case is essentially a categorization into centuries, is there some reason you cannot simply remove the extraneous part:

    century = value - (value % 100)
    

    If you really need the ranges to start at 201, and so forth, then just subtract one before doing it, and back the one to correct.

    value -= 1;
    century = value - (value % 100) + 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sounds like a weird question, but say I have something like this: $.post( /myajax.php,
I know that sounds really weird, but I am fairly new to C# and
OK, I know it sounds weird but I need to make a function that
This sounds like a weird title and probably not stated too well. But here's
This question may sound kinda weird but actually, I need to convince my mangement
I know it sounds weird but I need it for a workaround. So some
this sounds weird, but maybe there is exist one... i googled for it, but
I know it sounds weird but is there a way that an app (facebook
The question sounds weird but I'm getting an array of dictionaries as parsed result.
I know this could sound a little weird, but I need to pass some

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.