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 ответ
+ 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?