-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmike-style.js
85 lines (76 loc) · 2.05 KB
/
mike-style.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
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
let rows = [{
"clientid": 1,
"productid": 1000,
"name": "Season Pass",
"pricecategoryid": 1,
"pricecategory": "Adult",
"productprice": "$999.00",
"baseprice": "$999.00",
"discount": "$0.00",
"discountpercentage": "0.00",
"campaignid": null,
"campaignname": null,
"campaignuntil": null
}, {
"clientid": 1,
"productid": 1000,
"name": "Season Pass",
"pricecategoryid": 2,
"pricecategory": "Youth",
"productprice": "$699.00",
"baseprice": "$999.00",
"discount": "$300.00",
"discountpercentage": "0.00",
"campaignid": null,
"campaignname": null,
"campaignuntil": null
}, {
"clientid": 1,
"productid": 1001,
"name": "Super Pass",
"pricecategoryid": 1,
"pricecategory": "Adult",
"productprice": "$515.00",
"baseprice": "$515.00",
"discount": "$0.00",
"discountpercentage": "0.00",
"campaignid": null,
"campaignname": null,
"campaignuntil": null
}];
//PUT SOME CODE IN HERE THAT PROCESSES THE ROWS DATA ABOVE AND THEN CONSOLE LOGs THE DESIRED OUTPUT JSON (SEE BELOW THE DESIRED OUTPUT)
/*
Desired output: an array of products, each containing a pricing array
[{
"id": 1000,
"name": "Season Pass",
"baseprice": "$999.00",
"pricing": [{
"pricecategoryid": 1,
"pricecategory": "Adult",
"productprice": "$999.00",
"discount": "$0.00",
"discountpercentage": "0.00",
"campaign": {"id": null, "name": null, "until": null}
}, {
"pricecategoryid": 2,
"pricecategory": "Youth",
"productprice": "$699.00",
"discount": "$300.00",
"discountpercentage": "0.00",
"campaign": {"id": null, "name": null, "until": null}
}]
}, {
"id": 1001,
"name": "Super Pass",
"baseprice": "$515.00",
"pricing": [{
"pricecategoryid": 1,
"pricecategory": "Adult",
"productprice": "$515.00",
"discount": "$0.00",
"discountpercentage": "0.00",
"campaign": {"id": null, "name": null, "until": null}
}]
}]
*/