var a=[1.2,3,"3",4,5];
var countd=0;
for( i=0;i<=a.length;i++){
if(a[i]=="3"){ countd++;}
}
console.log(countd);
we use "for loop" to iterate with every element and it checks with the given value and the count increases every time the match is found.
above code run and print count of 3 in console log
lets make it dynamic function , so it will find the given element in the given array
function findgivenelement(array,elementtofind){
var countd=0;
for( i=0;i<=array.length;i++){
if(array[i]=="elementtofind"){ countd++;}
}
}
var a=[1.2,3,"3",4,5];
findgivenelement(a,"3");
above function work with only one dimensional array