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 - Using String Equality

Adding more than a word to the ignore list

Hello !

How could I add more words to the Censoring list using the same variable 'noun' (as per the example thought here)

Thanks, -Lionel

1 Answer

The next video covers blocking multiple words. Basically, it's similar to how you block one word, but instead of saying "if noun equals X, exit the program," you'd be saying "if noun equals X OR if noun equals Y OR if noun equals Z, exit the program."

Thanks for the response. Yes I shot the question too early. The very next track covered it like you have explained above. I have a follow-up question though. Instead of OR-ing these long 'noun.equals("<string>")' statements , is it possible to make 'String noun' an array and just input the words that we'd like to censor ?