I want to find out the string element which is exist or not in array. In other words, I can explain what I want to search. In the below code if I pass "text" to a function then how to find out the index of each element which consist "text" in array. that's the array and I want to print the index of text elements which exists in elements array but the condition is we only need to pass text in arguments.
"steps": [
{
"stepname": "Step 1",
"stepnum": 1,
"elements": [
"div-container-s1",
"text-1",
"text-2",
"text-3",
"image-1",
"image-2",
"button-1",
"button-2",
"image-3"
]
},
{
"stepname": "Step 2",
"stepnum": 2,
"elements": [
"div-container-s2",
"text-4",
"text-5",
"text-6",
"image-4",
"image-5",
"image-6",
"form-1",
"input-1",
"button-3",
"dropdown-1"
]
},
{
"stepname": "Step 3",
"stepnum": 3,
"elements": [
"div-container-s3",
"text-7",
"text-8",
"text-9",
"image-7",
"text-10",
"text-15",
"text-16",
"text-17",
"text-18",
"image-10",
"image-11",
"image-12",
"image-13",
"image-8",
"image-9",
"text-11",
"text-12",
"text-13",
"text-14"
]
}
],
function myFunction(elementType){
//code goes here
}
myFunction('text');
//output should be 0,1,2,3 because it contains "text"