Creating a list of values for Math.min? Wheres My NaN!

Using

var minWT = Math.min(ci_wt_clock_position1, ci_wt_clock_position2, ci_wt_clock_position3)

I get my expected result - a number. The columns are recognised as being numbers. However, there are 12 of these columns to consider and some of them may be 0 or empty so I need to qualify them before use. With the following code I make sure there is a usable number in the column, and if so add the column to vPositions.

var vPositions = ‘’
if (ci_wt_clock_position1 !=0 && ci_wt_clock_position1 !=null){ vPositions = ci_wt_clock_position1;}
if (ci_wt_clock_position2 !=0 && ci_wt_clock_position2 !=null){ vPositions = vPositions + ', '+ ci_wt_clock_position2;}
if (ci_wt_clock_position3 !=0 && ci_wt_clock_position3 !=null){ vPositions = vPositions + ', '+ ci_wt_clock_position3;}

application.output(vPositions) //I get the list of column values as expected

However if I feed that var to - var minWT = Math.min(vPositions) I get NaN as a result. I suppose its taking the column values as a string rather than a list of values. I also tried this as an array but minWT always comes out as NaN!

Q. Can I get the ‘Math.min’ to take this variable as a list of comma separated values (just as it does with Math.min(ci_wt_clock_position1, ci_wt_clock_position2, ci_wt_clock_position3) )?

Appreciate feedback.

You get the NaN because it is a string, as you said. I think it is easier if you use an array instead:

	var vPositions = [];
	if (ci_wt_clock_position1){ vPositions.push(ci_wt_clock_position1);}
	if (ci_wt_clock_position2){ vPositions.push(ci_wt_clock_position2);}
	if (ci_wt_clock_position3){ vPositions.push(ci_wt_clock_position3);}
	
	vPositions.sort();
	
	var minWT = vPositions[0];

Provided there is at least one valid value.

Joas:
You get the NaN because it is a string, as you said. I think it is easier if you use an array instead:

	var vPositions = [];
if (ci_wt_clock_position1){ vPositions.push(ci_wt_clock_position1);}
if (ci_wt_clock_position2){ vPositions.push(ci_wt_clock_position2);}
if (ci_wt_clock_position3){ vPositions.push(ci_wt_clock_position3);}

vPositions.sort();

var minWT = vPositions[0];


Provided there is at least one valid value.

Thanks Joas, that makes a lot of sense having seen it like this.
Cheers