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 trial

Java Java Basics Perfecting the Prototype Censoring Words - Looping Until the Value Passes

Zak Hardy
Zak Hardy
1,077 Points

Challenge troubles

Hi,

There isn't anywhere else to post this... so I thought I would post here. I'm having trouble with the challenge, finding it really hard.

question: "We want to move that prompting code into a do while loop. Wrap the code into a do while code block and check in the while condition to see if who is "banana" so that the loop continues."

I can't really apply what I just learnt to this, can't properly figure it out.

any help? thanks.

1 Answer

Harry James
Harry James
14,780 Points

Hey Zak!


What you want to do here is initialize the who variable outside of the do/while loop but don't set a value for it.

After that, we want to open the do loop where we keep all of the code that is provided.

Then, close the do loop.

Finally, we add our while statement just after the curly brace where we're checking to see if who is equal to banana, ignoring the case. We check this inside of the parentheses of the while statement.


Hope it helps and if you're still stuck with the challenges, give me a shout and I'll help you with the bit you're stuck on :)

Edit: Updated my code because I misread the Code Challenge! I was in a rush, sorry!