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

Dakota Strege
Dakota Strege
3,005 Points

I think this looks identical to the code in the video... Yet errors?

String noun; boolean isInvalidWord; do { noun = console.readLine("Enter a noun: "); isInvalidWord = (noun.equalsIgnoreCase("dork") || noun.equalIgnoreCase ("jerk)); if (isInvalidWord) { console.printf("That language is not allowed. Try again. \n\n"); } } while(isInvalidWord);

I get 5 errors

TreeStory.java:26: error: not a statement
if (isInvalidWord) {
^
TreeStory.java:26: error: ';' expected
if (isInvalidWord) {
^

Dakota Strege
Dakota Strege
3,005 Points

Never mind... I figured it out...

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I believe the problem you might be having is here:

isInvalidWord = (noun.equalsIgnoreCase("dork") || noun.equalIgnoreCase ("jerk));

The string "jerk" is not finished with quotes so it thinks the rest of that is part of the string. Try this:

isInvalidWord = (noun.equalsIgnoreCase("dork") || noun.equalIgnoreCase ("jerk"))

Notice the closing quotes around the word "jerk". Hope this helps! :sparkles: