How do you count results within an array?
I am counting the occurrences of a pattern in an array and could like it to return as
[0, 0, 0]
For example with each element of the array representing a search result.
This is what I've done so far... but it seems to only return [object object]...
pages=[
"Lorem Ipsum is simply dummy text of the printing and typesetting industry."
,
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout",
"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable."
]
pattern = prompt("Enter a search string")
var count = {};
for(i=0; i<pages.length; i++)
{
for(j=0; j<pattern.length; j++)
{
if((pages[i].toLowerCase()
.indexOf(pattern.toLowerCase()
.charAt([j])))<0)
{
count[i]++;
}
}
}
alert(count);
console.dir( count );