-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic_Foundation_2.js
More file actions
85 lines (80 loc) · 1.29 KB
/
Basic_Foundation_2.js
File metadata and controls
85 lines (80 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function biggieSize(){
for(i=0; i<x.length; i++){
if(x[i]>0){
x[i] = "big";
}
}
return x;
}
x = [-1,3,5,-5]
biggieSize(x);
function printLowReturnHigh(){
var low = x[0];
var high = x[0];
for(i=0; i<x.length; i++){
if(x[i]>high){
high = x[i];
}
if(x[i]<low){
low = x[i];
}
}
console.log(low);
return high;
}
var x = [1,3,5,8]
printLowReturnHigh(x);
function printPenultimateReturnFirstOdd(){
var penult = x[x.length-2];
for(i=0; i<x.length; i++){
if(x[i]%2 !== 0){
var FirstOdd = x[i];
break;
}
}
console.log(penult);
return FirstOdd;
}
x = [1,7,5,6,50];
printPenultimateReturnFirstOdd(x);
function doubleVision(){
nuarr = [];
for(i=0; i<x.length; i++){
nuarr.push(x[i]*2);
}
return nuarr;
}
x = [1,2,3]
doubleVision(x);
function countPos(){
var count = 0;
for (i=0; i<x.length; i++){
if(x[i]>0){
count++;
}
}
x[x.length-1] = count;
return x;
}
x = [-1,1,1,1]
countPos(x);
function evensAndOdds(){
var oddCount = 0;
var evenCount = 0;
for(i=0; i<x.length; i++){
if(x[i]%2 !==0){
oddCount++;
}else(oddCount = 0);
if(x[i]%2 ===0){
evenCount++;
}else(evenCount = 0);
if(oddCount%3 ===0){
console.log("That's Odd!");
}
if(evenCount%3 ===0){
console.log("Even more so!");
}
}
}
x = [1,2,3,4,1,1,1,2,2,2]
evensAndOdds(x);