You need to sign in to do that
Don't have an account?
Sowjanya Saride
' Get Started with Apex ' running successfully but says Challenge Failed
Hello Ohana!
I am trying to pass the ' Get Started with Apex ' Challenge in
Developer Beginner >> Apex Basics & Database >> Get Started with Apex
Trail.
My Code runs successfuly in my Dev Console and can see the System Debug Logs.
But, it says My challenge is Failed. I Don't Understand . Please Help. Posting screenshots below :
PS: I tried this in two different Playgrounds but no luck.
Thanks,
L
I am trying to pass the ' Get Started with Apex ' Challenge in
Developer Beginner >> Apex Basics & Database >> Get Started with Apex
Trail.
My Code runs successfuly in my Dev Console and can see the System Debug Logs.
But, it says My challenge is Failed. I Don't Understand . Please Help. Posting screenshots below :
< public class StringArrayTest { public static List<String> generateStringArray(Integer n ) { List<String> returnStringList = new List<String>(); for( Integer i = 0 ; i < n ; i++ ) { returnStringList.add('Test'+i); system.debug( returnStringList[i]); } return returnStringList; } } >
PS: I tried this in two different Playgrounds but no luck.
Thanks,
L
Thanks for the reply.
I copy pasted your last snippet and it worked. Thank you!
But, Can you please make me understand what is it diff from your code and mine. where am I going wrong or what am I missing ?
Only difference I see is, generateStringArray(Integer n) has a return type of String[] than a List - List<String>
I tried applying only this change, but still my code failed to pass the challenge. When I copy pasted your code, it worked.
Where is that I am going wrong. Kindly reply.
Thanks,
L
My Coding is returning Array of String[] rather than list
In your code below,
<
public class StringArrayTest {
02 public static String[] generateStringArray(Integer n)
03
04 {
05 List<String> listString = new List<String>();
06 for(Integer i=0;i<n;i++)
07 {
08 listString.add('Test '+i);
09 System.debug(listString[i]);
10 }
11 return listString;
12
13 }
14
15 }
>
You are returning List of string type not an array. How is it working in this scenario. Please throw light on this.
Thank you,
L