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 :)

30th Jan 2019, 2:56 AM
Trevor
Trevor - avatar
1 Antwort
+ 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?
30th Jan 2019, 3:01 AM
James
James - avatar