Posted by **Adam** on Monday, November 21, 2011 at 6:31pm.

How do take this following javascript and put in external javascript.

<html>

<head>

<script language="javascript" type="text/javascript">

test();

function counter(array){

var negatives =0;

var zeroes =0;

var positives=0 ;

var i=0;

for(i=0;i<array.length;i++)

{

switch (true )

{

case (array[i] == 0) :

zeroes++;

break;

case (array[i] > 0) :

positives ++;

break;

case (array[i] < 0) :

negatives ++;

break;

}

}

return "Negatives = "+negatives+"\nZeroes = "+zeroes+"\nPositives = "+positives;

}

function test(){

var myIntArray = new Array(10);

var i=0;

for(i=0;i<10;i++){

var num = prompt("Please enter a number","Please enter a number");

myIntArray[i] = parseInt(num);

}

var output = counter(myIntArray);

alert (output);

}

</script>

</head>

<body onload="test()">

</body>

</html>

## Answer This Question

## Related Questions

- Javascript - I would like the function test to get the input from the user and ...
- JAVASCRIPT - Start button won't work for a scolling marquee. Below is the ...
- JavaScript - I'm working on a javascript exercise. I have written function ...
- Javascript - I need help these javascript exericses: Input: A text string, using...
- JavaScript - I need help these javascript exericses: Input: A text string, using...
- programming - JavaScript - /*Hello, I really hope someone can help me out with ...
- Javascript - Can you check my code and tell me why the prompts are not showing ...
- Computer Science-Javascript - Can you check my code and tell me why the prompts ...
- Statistics - Joint probability density function is: x + y where 0<x<1 and ...
- Computer Science - Suppose X is a random variable and Y = aX + b is a linear ...

More Related Questions