function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prerna Raj 7Prerna Raj 7 

Error Variable does not exist

I am new to coding and am still learning. I am getting the error for  "variable does not exist : i " in my code below -   I have made the 2 lines in which i am getting the error bold

trigger LeadingCompetitor on Opportunity (before insert, before update) {
    
    for (Opportunity opp : Trigger.new){
        //Add all prices to our list in order of competitors
            List<Decimal> competitorPrices = New List<Decimal>();
            competitorPrices.add(opp.Competitor_1_Price__c);
            competitorPrices.add(opp.Competitor_2_Price__c);
            competitorPrices.add(opp.Competitor_3_Price__c);
       
        //Add all competitors to our list in order 
            List<String> competitorName = New List<String>();
            competitorName.add(opp.Competitor_1__c);
            competitorName.add(opp.Competitor_2__c);
            competitorName.add(opp.Competitor_3__c);
        
        //Loop throughall competitors to find the position of the lowest price
            Decimal lowestPrice;
            Integer lowestPricePosition;
        
            for (Integer i = 0; i < competitorPrices.size(); i++); {
                Decimal currentPrice = competitorPrices.get(i);
                if(lowestPrice == Null || currentPrice < lowestPrice) {
                    lowestPrice = currentPrice;
                     lowestPricePosition = i;
            }
            }
        //Populate the leading competitor field with the competitor matching the lowest price position
                   opp.Leading_Competitor__c = competitorName.get(lowestPricePosition);
                
    
    }    
}
Prathyusha Balguri 4Prathyusha Balguri 4
The error is in  line  -  for (Integer i = 0; i < competitorPrices.size(); i++); {
Remove ';' before the curly brace. 
Prerna Raj 7Prerna Raj 7
Thank you so much....:)