“String.Contains JavaScript” Kode Jawaban

JavaScript string berisi

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

console.log(string.includes(substring));
Cautious Crane

string berisi dalam javascript

const string = "foo";
const substring = "oo";

console.log(string.includes(substring));
2 Programmers 1 Bug

string javascript berisi fungsi

s = "Hello world";
console.log(s.includes("world"));
Curious Cormorant

JavaScript berisi 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)
Grepper

String.Contains JavaScript

var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
	alert("Not again");
}
Misty Manatee

String.Contains JavaScript

let string = "This string contains pizza";
if(string.includes("pizza") {
	console.log("It's pizza time!");   
}
Bench Cubed

Jawaban yang mirip dengan “String.Contains JavaScript”

Pertanyaan yang mirip dengan “String.Contains JavaScript”

Lebih banyak jawaban terkait untuk “String.Contains JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya