• Jennifer T Vega
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi - I'm not sure why I'm getting the following error when I try to submit my challenge: 

Challenge Not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

Below is my code:
public class StringArrayTest {

//public static method called 'generateStringArray'
//return an array (list) of strings.
//each string must have a value in this format: 'Test n' (n=index of the current string in the array)
//The number of returned strings is specified by the integer parameter to the 'generateStringArray'method

    public static list<String> generateStringArray(Integer parameter){
        
        
        
        List<String> listofStrings = new List<String>();
        //listofStrings.add('Test n'); Adding this before the loop didn't give me values for n
        //List<String> listofStrings = new List<String>{'Test n'}; Same issue as above. Defined too early. 
       
     
     
        for(Integer n=0; n<= parameter; n++){
           listofStrings.add('Test '+n);
            
            
           //System.debug('n:'+n); This helped me to find out that I am getting the numbers for n that I want. 
            
            //System.debug('listofStrings: '+listofStrings); This was too early and inside the loop, so I was
            //getting a line in the system debug each time the loop ran. 
            
        }
      System.debug('listOfStrings:' +listofStrings);
               
        return listofStrings;
        
    }
    
    
}

And this is what I've put in Execute Anonymous:
List<String>listofStrings = StringArrayTest.generateStringArray(5);
Hi - I'm not sure why I'm getting the following error when I try to submit my challenge: 

Challenge Not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

Below is my code:
public class StringArrayTest {

//public static method called 'generateStringArray'
//return an array (list) of strings.
//each string must have a value in this format: 'Test n' (n=index of the current string in the array)
//The number of returned strings is specified by the integer parameter to the 'generateStringArray'method

    public static list<String> generateStringArray(Integer parameter){
        
        
        
        List<String> listofStrings = new List<String>();
        //listofStrings.add('Test n'); Adding this before the loop didn't give me values for n
        //List<String> listofStrings = new List<String>{'Test n'}; Same issue as above. Defined too early. 
       
     
     
        for(Integer n=0; n<= parameter; n++){
           listofStrings.add('Test '+n);
            
            
           //System.debug('n:'+n); This helped me to find out that I am getting the numbers for n that I want. 
            
            //System.debug('listofStrings: '+listofStrings); This was too early and inside the loop, so I was
            //getting a line in the system debug each time the loop ran. 
            
        }
      System.debug('listOfStrings:' +listofStrings);
               
        return listofStrings;
        
    }
    
    
}

And this is what I've put in Execute Anonymous:
List<String>listofStrings = StringArrayTest.generateStringArray(5);