Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!