/
weblog.html
46 lines (39 loc) · 905 Bytes
/
weblog.html
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
<!DOCTYPE html>
<html>
<head>
<title>Count Operation</title>
</head>
<script type="text/javascript">
function findSeq(weblog) {
var newLog = [];
for (var i=0; i<weblog.length; i++) {
var log = {
"visitor": "",
"allLogs": []
}
if (newLog.hasOwnProperty(weblog[i].visitor)) {
newLog[key].push(weblog[i].url);
} else {
var key = weblog[i].visitor;
newLog.push({key: [weblog[i].url]});
}
}
console.log(newLog);
}
var weblog = [
{'visitor' : 'a', 'url': '1'},
{'visitor' : 'c', 'url': '5'},
{'visitor' : 'b', 'url': '2'},
{'visitor' : 'b', 'url': '1'},
{'visitor' : 'c', 'url': '1'},
{'visitor' : 'a', 'url': '3'},
{'visitor' : 'c', 'url': '4'},
{'visitor' : 'a', 'url': '5'},
{'visitor' : 'c', 'url': '1'},
{'visitor' : 'b', 'url': '2'}
];
console.log(findSeq(weblog));
</script>
<body>
</body>
</html>