Create a Node.js Controller which have the following functionality:
Convert the string S:
S = "Magic=3\nMagic,F=1\nMagic,1=1\nMagic,2=2\nMagic,3=13\nMaxEAEquityDD=10\nMaxEAEquityDD,F=1\nMaxEAEquityDD,1=10\nMaxEAEquityDD,2=1\nMaxEAEquityDD,3=15"
to this:
Parameters : {
{
name: "Magic",
value: "3",
chequed: "1",
start: "3",
step: "2",
end: "13",
steps: {3,5,7,9,11,13}
},
{
name: "MaxEAEquityDD",
value: "10",
chequed: "1",
start: "10",
step: "4",
end: "15",
steps: {"10","14","15"}
}
}
The String S could have n input parameters (not only Magic and MaxEAEquityDD).
The values of each parameter are in a consecutive order (Magic=3 | Magic,F=1 | Magic,1=3 | Magic,2=2 | Magic,3=13)
steps are created with the 3 values (start,step,end)
- Start is the first value (in Magic is 3)
- steps is the amount you have to add (in Magic 3 + 2 = 5)
- end is the upper limit (in Magic is 13).
Note that (value + last step) > end then the last value is end
(for example in MaxEAEquityDD => (14 + 4) = 18 > 15), then last step is 15 = end