Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script language="javascript" type "text/javascript">
- function initArray(n) {
- var arrayLocation = 0;
- var numbers = [];
- for (var x = 1; x <= n; x++) {
- numbers[arrayLocation] = Math.floor(Math.random() * 101);
- arrayLocation++;
- }//end of for
- document.write(numbers + "<br/>");
- return numbers;
- }//end of function initArray
- function checkIfInArray(n, anArray) {
- var x = numbers.length;
- var doesContain = 0;
- for (var x = 0; x > numbers.length; x++) {
- if (numbers[x] == n) {
- doesContain = 1;
- break;
- } else {
- doesContain = 0;
- }//end of else
- }//end of for
- if (doesContain = 0) {
- document.write("The array does not contain the number " + n);
- } else {
- document.write("The array does contain the number " + n);
- }//end of else
- }//end of function checkIfInArray
- checkIfInArray(11, initArray(10));
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement