if (str.indexOf("Yes") >= 0)
…or you can use the tilde operator:
This works because
-1 if the string wasn’t found at all.
Note that this is case-sensitive.
If you want a case-insensitive search, you can write
if (str.toLowerCase().indexOf("yes") >= 0)
The latter is a regular expression or regex.
/indicates this is a regex
yesmeans that the regex will find those exact characters in that exact order
/ends the regex
isets the regex as case-insensitive
.test(str)determines if the regular expression matches
To sum it up, it means it will see if it can find the letters
sin that exact order, case-insensitively, in the variable