5. 5
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
Requirement
5
6. 6
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
2. The AppliedTaxCode will contain the
value from the last Connection
object.
Requirement
6
7. 7
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
2. The AppliedTaxCode will contain the
value from the last Connection
object.
3. If the EndOfConnection field is true,
create a separate output object.
Requirement
7
8. 8
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
2. The AppliedTaxCode will contain the
value from the last Connection
object.
3. If the EndOfConnection field is true,
create a separate output object.
4. If there are EndOfConnection fields
that are true and this is not the last
object inside the Connections array,
create a new output object
containing all the false Connection
objects before this, and using this
last object’s TaxCode.
Requirement
8
9. 9
● Logic:
1. For each object from the
FlightOptions array, create one
output object inside the output array.
2. The AppliedTaxCode will contain the
value from the last Connection
object.
3. If the EndOfConnection field is true,
create a separate output object.
4. If there are EndOfConnection fields
that are true and this is not the last
object inside the Connections array,
create a new output object
containing all the false Connection
objects before this, and using this
last object’s TaxCode.
5. Each AppliedConnections object in
the output must have:
1. A hardcoded Type value
“Connection”.
Requirement
9
13. 13
2) Change all the EndOfConnection to true for the last Connection object from the Connections
array.
Building the Solution
14. 14
3) flatten the array of arrays to be just one array.
Building the Solution
15. 15
4) Add a new field to keep track of the object’s index, basing on the EndOfConnection field.
(For each EndOfConnection=true, stop incrementing the index.)
Building the Solution
Index 1
Index 2
Index 1
Index 1
Index 1
Index 3
Index 2
16. 16
5) Add a new field to keep track of the final AppliedConnections object’s (first) index where the
object in question will be added.
Note: This is calculated using the object’s index + 1 (to start at 1) and then minus the previously
added indexBasedOnEOC field.
Building the Solution
Index 0
Index 2
Index 3
Index 4
17. 17
6) Separate the objects based on the EndOfConnection value (true or false).
Building the Solution
18. 18
7) Take only the objects that are inside the “true” list.
Building the Solution