0
Why doesnât my code work? [SOLVED]
Im new to JavaScript and I want to have it where if there in a âtâ anywhere in the text you put in it will return what I want how do I do this Example: âHelloâ //returns false âtâ // returns true âtestâ //returns true âToggleâ //returns false âthis is a testâ // returns true https://code.sololearn.com/WsYrqkttwIJ9/?ref=app P.s sorry any typoâs :)
1 Answer
+ 6
if ( input1.toLowerCase().includes("t") )
.toLowerCase() makes the string entirely lowercase, so that the input can be either "T" or "t" and still be detected.
.includes() returns true if its parameter string is contained anywhere within the main string.
This will be true if "t" is at the middle or end of a word, even if it isn't at the beginning. Is this what you wanted?