How do I check if a string contains another string in JavaScript? Normally, I would use the String.contains() method, but I don't think I can. What can I do?
javascript string
String.prototype.indexOf returns the position of the string. Returns -1 if the string is not included.
var string = "foo",
substring = "oo";
console.log(string.indexOf(substring) > -1);
© 2024 OneMinuteCode. All rights reserved.