Dopo aver fatto le correzioni suggerite da antotan puoi togliere l'if e sostituirlo con
codice:
verità = g1[i] == g1[g1.length - 1 - i];