My question is how to get index of array which contains/includes string value. See my code below to get the result I want.
This is simple code to get index of array:
var myarr = ["I", "like", "turtles"];
var arraycontainsturtles = (myarr.indexOf("turtles"));
console.log(arraycontainsturtles) // the result will be 2
I want to get the index result with a code sample below:
var myarr = ["I", "like", "turtles"];
var arraycontainsturtles = (myarr.indexOf("turt"));
console.log(arraycontainsturtles) // i want the result will be 2 with the contains string just the 'turt' only.
How to get the index with a contains string value like at the sample number 2? The real result of the number 2 will be -1.
How do I do that?