html
html
1
2
3
4
5
6
7
8
9
10
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
<!-- Look at JS page -->
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function counter(input){
var sop=0;
var non=0;
if(!(input instanceof Array)){
console.log("IT'S NOT AN ARRAY!!!");
console.log("-------");
return null;
}
for(var i=0; i<input.length;i++){
if(input[i]>=0){
sop+=input[i];
}else{
non+=1;
}
}
console.log("sum of positive numbers ="+sop);
console.log("count of negative numbers="+non);
console.log("-------");
}
counter([1,2,3,4,5,8,9,0,7,6,54,6]);
counter([1,-3,3,4,5,7,-2,-9,0,9,-6]);
counter(123);
counter("test");
counter([]);
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run