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.


Dylan Bailey
Dylan Bailey
Front End Web Development Techdegree Student 9,221 Points

.toLowerCase() on prompt?

Guil is showing multiple ways to return a user's search as lowercase. I added the method to my initial prompt() call and had no issues.

const search = prompt('Search for a product.').toLowerCase();

Is this a valid way of calling the method? Or would the following example be best practice?

const search = prompt('Search for a product.');
searchText = search.toLowerCase();

1 Answer

Steven Parker
Steven Parker
217,519 Points

The more compact first form would be fine unless there might be a reason to refer to the original response later in the code. In that case, the 2nd form would be preferable.