Answers for "js string contains"

24

check for substring javascript

const string = "javascript";
const substring = "script";

console.log(string.includes(substring));  //true
Posted by: Guest on July-06-2020
4

js string contains

'Bandeira do Brasil'.includes('brasil'); // retorna false
Posted by: Guest on February-08-2021
2

js string contains

var string = "foo";
var substring = "oo";

console.log(string.indexOf(substring) !== -1);
Posted by: Guest on March-24-2020
0

js string contains

let example = "Example String!";
let ourSubstring = "Example";

if (example.indexOf(ourSubstring) != 0) {
	console.log("The word Example is in the string.");
} else {
	console.log("The word Example is not in the string.");
}
Posted by: Guest on October-12-2021
0

js string contains

let str = "Example String!";

/Example/.test(str);
Posted by: Guest on October-12-2021
0

js string contains

let example = "Example String!";
let ourSubstring = "Example";

if (str.includes(ourSubstring, 7)) {
	console.log("The word Example is in the string.");
} else {
	console.log("The word Example is not in the string");
}
Posted by: Guest on October-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language