I am taking a Javascript class and my instructor used the following code:
if('question-'.indexOf('question-1')){
//code
}
He claims this produces a true result and will execute the code in the code block (and it does work for him). I have tried running this in console, and I always get a -1 result. I am confused on how indexOf works in this case. (I know -1 means not found). But, in this case, some of the characters are there, just not every single one indicated in the string passed into indexOf. Does every single character have to be there and match? Or in this case was it producing a true result because some of the characters were there?