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 trialK W
3,736 PointsA little help please......
Declare an int variable named 'numberOfFrogs' and set it to the number of elements in the array using the array's 'length' property.??? my answer*** String[]frogNames = {"mike","ben","kris"}; String bestFrog = frogNames[2]; Random randomGenerator = new Random(); int numberOfFrogs = randomGenerator.Int(frogNames.length);
3 Answers
Valery Kukatov
6,996 PointsOkay, so after I fixed your code. I did the code challenge as well. Your code is almost correct for the challenge. Your error comes up only because you are using randomGenerator. The challenge never asked for the randomGenerator to be placed. As well your bestFrog string is wrong according to challenge, what you put in is the last frog.
K W
3,736 Pointsthank you for taking the time to respond
Valery Kukatov
6,996 PointsWell I'd like to help you out if you can fix it. :)
String[]frogNames = {"mike","ben","kris"};
String bestFrog = frogNames[2];
Random randomGenerator = new Random();
int numberOfFrogs = randomGenerator.Int(frogNames.length);
K W
3,736 PointsI got it, thought a randomGenerator was required....thanx again for your time
Valery Kukatov
6,996 PointsValery Kukatov
6,996 PointsYou should try to use the Markdown Cheatsheet. The code is very confusing and hard to know what you did wrong when it's written as just text. you have to use three ` before and after the code. This thing called backstick and is located to the left of number 1/ exclamation mark. Once that's done, We can help better. Sorry for the inconvenience.