I'm trying to wring a script that outputs an array and counts the number of elements in the array based on user input.
<script>
// Function searches a given array and counts the number of times an element appears in the array.
function countOccurences(numArray, num) // function
{ //parameters
var count = 0;
if(array[i] == 2)
count++;
}
</script>
</head>
<body>
<script>
var num = [2, 6, 33, 1, 77, 2, 98]; <!-- array -->
document.write("<p>"+nums.toString()+"</p>"); <!-- fill the array-->
var count = parseFloat(prompt("Please enter number to search for", "")); <!--ask for the numer to search -->
// linear search
var p = countOccurences(nums, key) ;
document.write("<p>Value "+p+" was not found in array </p>"); //output the count
</script>
</body>
</html>
<!-- ... -->- wrong comments for JavaScript