JSFiddle - React, Tailwind, and code Playground

HTML

<FORM NAME="calc" method="POST">

<button TYPE="button" ID="calc">CALC</button>
<input type="text" name="stuff[]" class="inputField" id="first"/>
<input type="text" name="stuff[]" class="inputField" id="second"/>
<input type="text" name="stuff[]" class="inputField" id="third"/>

</FORM>

JavaScript

$('#calc').click(function(){

Math.GCD = function(numbers) {
  for (var i = 1 ; i < numbers.length ; i++){
  	if(numbers[0]==""){
    		$.each($('.inputField'),function(){
          if($(this).val()!=""){
          	   numbers[0] = $(this).val();
               return false;
          }
        });
    }   
    if(numbers[0]!="" && numbers[i]!=""){
    	numbers[0] = twogcd(numbers[0], numbers[i])
    }
  }
  return numbers[0];
  
 if (numbers[i] === '' || numbers[i] === 0) { 
    numbers[0] = twogcd(numbers[0], numbers[i])
    };
  function twogcd(first, second) {
    if (first < 0) first = -first;
    if (second < 0) second = -second;
    if (second > first) {var temp = first; first = second; second = temp;}
    while (true) {
        first %= second;
        if (first == 0) return second;
        second %= first;
        if (second == 0) return first;
    }
   }
};

Math.LCM = function(first,second) {
    return first * (second / this.GCD(first, second));
};

var first   = $("#first").val();
var second   = $("#second").val();
var third = $("#third").val();

var numbers = [first,second,third];

var GCDresult = Math.GCD(numbers);


alert(GCDresult);
});