Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialUssaid Iqbal
Courses Plus Student 765 PointsGeneral Question
As we are trying to generate random fact what if we want to show facts in sequence ?? like on click 1st member of array then on 2nd click 2nd member and so on???
1 Answer
David Clausen
11,403 PointsWell instead of just grabbing a random index, grab the index and each time you display a fact add to that index
//pseudo code
OnClick()
fact = [index]
index ++
//if index goes over array
if (index < array.length)
index=0
I dont know what code your using, probably Java for this project. But this would solve it. I assume you know how to implement this if your this far.
Ussaid Iqbal
Courses Plus Student 765 PointsUssaid Iqbal
Courses Plus Student 765 PointsPlease Elaborate your answer or help me with this
public String[] mMixLetters ={"A","B","C"......................};
//that's the code and i want to get the array element in sequence not randomly how to modify this??