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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:20:39+00:00 2026-06-10T17:20:39+00:00

I have four numbers that can possible be the same, but or most likely

  • 0

I have four numbers that can possible be the same, but or most likely different. Basically I want this function to chose no number of they are equal, but if they aren’t, pick the lowest one, and if there are two that are the same, to just pick one of them and go with that.

Like for example I have 3434, 3396, 3414, and 3374. Well I want the function to return to me say 0 if they’re all the same, 1 for the first one and so on. So in this situation I would need to be returned 4.

But if the numbers were 321, 576, 812, and 321 it would return to me 1.

I’ve been at this for a couple of days now and I just can’t seem to find any way of doing what I need to do. Anyone know something that could make this work magically? Thanks!

EDIT
My approach had me doing something along the lines of creating an array sorting it and trying to use the last result, but when I sort the array, the keys get messed up so I don’t know which value it belonged to

 var choices = new Array();
 choices[1] = parseInt(value1);
 choices[2] = ...
 choices = choices.sort();
 //and then I ran into the problem that my keys being not starting 
 //with 0, it added an element which I was able to remove by doing this
 choices = choices.splice(0,4);

And then I’m stuck for there

  • 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-10T17:20:41+00:00Added an answer on June 10, 2026 at 5:20 pm

    Here’s a start on the journey to answering your question. As others have pointed out, this code does not handle all the cases you mention; this is deliberate.

    How can I pick the lowest number from a list of numbers?

    Hand-rolled way; O(n) and one pass:

    var myList = [3434, 3396, 3414, 3374];
    var min = Infinity;
    var minIndex = -1;
    var current;
    
    for (var i=0; i<myList.length; i++)
    {
        current = myList[i];
        if (current < min)
        {
            min = current;
            minIndex = i;
        }
    }
    
    // the value you want is in minIndex
    

    Far more concise; also O(n) but two passes through the array:

    var min = Math.min.apply(null, myList);
    var minIndex = myList.indexOf(min);
    

    N.B Array.indexOf requires a shim in older versions of IE.


    Basically I want this function to chose no number of they are equal

    This exercise, as they say, is left to the reader.

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

Sidebar

Related Questions

I have a text file that stores combinations of four numbers in the following
I have this great function that parses a field into a pivot table consisting
I think this is not really possible but worth asking anyway. Say I have
I have four integer numbers a, b, c, d, and integer x ϵ [1,
I have column in a postgresql database. They are lottery numbers. Four digits in
i have four radio buttons , and i want to set a text for
i have four tables user-question contains two columns: questionID, userID, the questions that the
i have four imageviews in a linear layout in such a manner that only
I want to match and replace a number of four digit numbers in a
This seems like it should be fairly simple, but for some reason I can't

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.