Answers for "includes in javascript"

56

javascript string contains

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

console.log(string.includes(substring));
Posted by: Guest on December-21-2019
30

javascript string includes

'Blue Whale'.includes('blue')  // returns false
Posted by: Guest on March-19-2020
28

javascript contains substring

var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
	alert("Not again");
}
//use indexOf (it returns position of substring or -1 if not found)
Posted by: Guest on July-18-2019
34

javascript includes

const pets = ['cat', 'dog', 'bat'];

console.log(pets.includes('cat'));
// output: true
Posted by: Guest on June-12-2020
10

contains example in java

String s1 = "My name is GFG"; 
  
// prints true 
System.out.println(s1.contains("GFG")); 
  
// prints false 
System.out.println(s1.contains("geeks"));
Posted by: Guest on May-11-2020
5

includes in javascript

var colors = ['yellow', 'red', 'pink'];
var string = 'yellow and red are pretty cool';

// outputs false
console.log(colors.include('blue');
// outputs true
console.log(string.includes('yellow');
Posted by: Guest on October-04-2020

Code answers related to "includes in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language