const list = [12, 5, 80, 34, 5];
const search = 5;
let last = 0;
let counter = 0;

while (last >= 0) {
  last = list.indexOf(search, last);
  if (last != -1) {
    last++;
    counter++;
  }
}
alert("There is a total of " + counter + " occurrences of the value " + search);