-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayTest.js
More file actions
62 lines (48 loc) · 1.12 KB
/
arrayTest.js
File metadata and controls
62 lines (48 loc) · 1.12 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
var myObjArray = {
"_id" : 100,
"scores" : [
{
"type" : "exam",
"score" : 47.42608580155614
},
{
"type" : "quiz",
"score" : 44.83416623719906
},
{
"type" : "homework",
"score" : 19.85604968544429
},
{
"type" : "homework",
"score" : 39.01726616178844
}
]
}
//console.log(myObjArray.scores[0].score);
var DEBUG = true;
if (DEBUG) {
debugger
};
var lowestScoreIndex = 0 // set to myObjArray.scores[0].score - first object in the array
var lowestScoreObject = myObjArray.scores[lowestScoreIndex];
console.log(lowestScoreObject);
for (var i = 1; i < myObjArray.scores.length; i++) {
if (myObjArray.scores[i].score < lowestScoreObject.score) {
lowestScoreIndex = i // set to position of myObjArray.scores[i].score;
lowestScoreObject = myObjArray.scores[i];
console.log("new lowestScoreIndex found ");
console.log(lowestScoreObject);
console.log("lowestScoreIndex: [" + lowestScoreIndex + "]");
if (DEBUG) { // if(myObjArray.scores)
debugger
};
}
if (DEBUG) { // for ()
debugger
};
};
if (DEBUG) { //
debugger
}
console.log("lowest score found: " + lowestScoreObject);