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

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Student Record Search Challenge Solution

gaby ibarlucea
gaby ibarlucea
4,213 Points

Solutions to fix responses in different CaSeS?

What possible solutions would there be in case a response to search students was 'DAVE' and not 'Dave'? Since the search and equality operators are case sensitive, how could I make it so that even if a user typed in 'dAVE' or 'DAVE' or 'dave', the program would still print the information for 'Dave'?

1 Answer

Steven Parker
Steven Parker
231,275 Points

You could convert to a consistent case.

To make a comparison not case sensitive, just convert both operands to the same case. For example:

if (input.toLowerCase() == students[i].name.toLowerCase()) {