I am using variables for my numbers. I require the smallest number and so I use min() to achieve that but if I have multiple values it will only take them in chronological order.

var a = 98 ; var b = 82 ; var c = 61 ; var d = 80 ; var e = 89 ; var f = 61 ; var g = 82 ;
var z = Math.min ( a , b , c , d , e , f , g ) ;
var y = " this is the final value that determines everything ! " ;
if ( a == z ) { y = " a " } else if ( b == z ) { y = " b " } else if ( c == z ) { y = " c " } else if ( d == z ) { y = " d " } else if ( e == z ) { y = " e " } else if ( f == z ) { y = " f " } else if ( g == z ) { y = " g " } else { " you are an invalid " } ;
// if ( " you are an invalid " == true ) { " then you will burn in hell for all of your sins " }

In this example y equals both c and f, but we'll ignore f in this case. How can I get both values for further comparison? They are apart of a more complex system and the values are always changing so that sometimes there are more or less occurrences of the same values and some have noneatall.

(I thought about it for a bit while typing upto this point and think I have solved it, we will see)

But I guess that now I have a known minimum I can just compare all of the original values with the y factor.

(Okay, so I have tried alot of different things but they didn't work or was just repeating myself from before if statements)

(Maybe I should remove y? but I need y to tell me what value it has that is small ! so maybe if I try y = y + "*" Now I feel I am onto something, proving that typing this problem out has helped me once and for all to solve this for myself)

Let's let me try again from completed scratch:

var a = 98 ; var b = 82 ; var c = 61 ; var d = 80 ; var e = 89 ; var f = 61 ; var g = 82 ;
var z = Math.min ( a , b , c , d , e , f , g ) ;
var y = "" ;
if ( a == z ) { y = y + "a" }; if ( b == z ) { y = y + "b" }; if ( c == z ) { y = y + "c" }; if ( d == z ) { y = y + "d" }; if ( e == z ) { y = y + "e" }; if ( f == z ) { y = y + "f" }; if ( g == z ) { y = y + "g" } ;
// now what do I do now? ~ :\
// how can I break up y for further processing purposes?
// will I take a break from all of this typing and return to my problem at a later time?
// NO! you must complete now or never and die very painful death!
// but it usually works for me to take break?
// NO BREAKS! Now get back to work!
// okay Doctor Proactivation, fine, have it your way then and I will try my best to persevere instead of listening to the other of myself.
yA = y .split ( "" )
// I apologize for my inconstancy earlier, just previously before. But now I hit another wall made out of candystuffs. how can I see how many values there are for y[x]?
yL = y .length
//
// found bug in programme and went back to remove all "else" occurence -___-
// now I need to figure something to do for with my length and apply mind over matter to achieve results ^^'

I will return later to this for my time being.

"How can I get both values for further comparison?"

Not sure what you mean by this. The rest of your program doesn't do further comparison of the equal variables anyhow. If you just want to list all the variable names that contain the minimum value, you are going in the right direction with the second version of your program. I think you might want to edit your code slightly to something like the following:

var y = "The variable(s) that contain the minimum value(s) follow: <br />";

. . .

if (a == z){
  y = y + "a" + "<br />";
}

etc., etc.

Then, when all the variables have been compared to the min and the y string includes all the variable names it should, output y.

A couple other options you might consider:
i) use a switch statement instead of a bunch of if statements.
ii) if the number of variables gets large, consider creating an array to hold them. Then instead of having a large number of if statements, you could have a simple loop that goes through the array elements.

At first I have great difficulty for remembering what this is for but then the variables a-g reminds me of a music project I was playing with sound. In the example I was using the minimum thinking I can apply the opposite for a maximum results. I was only after the variables c and f from out of the group of a-g for placing them into the correlative patterns. Now I must find where I put that project, recovering this has newfound my influence.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.