Get The Middle Rows Of A Collection

Input collection: myCars21

YearMake Model
2016ToyotaCorolla
2014HondaCivic
2019ToyotaCamry
2018HondaCivic
2018HyundaiElantra
2020HondaAccord


Output collection: mySolution21a

YearMake Model
2019ToyotaCamry


Solution code:

//Create a collection
ClearCollect(myCars21,
{Year: 2016, Make: "Toyota", Model: "Corolla"},
{Year: 2014, Make: "Honda", Model: "Civic" },
{Year: 2019, Make: "Toyota", Model: "Camry" },
{Year: 2018, Make: "Honda",Model: "Civic"},
{Year: 2018, Make: "Hyundai", Model: "Elantra"},
{Year: 2020, Make: "Honda", Model: "Accord"}
);

//Get middle row code
ClearCollect(
    mySolution21a,
    Last(FirstN(myCars21,3))
);


Output collection: mySolution21b

YearMakeModel
2019ToyotaCamry
2018HondaCivic
2018HyundaiElantra


Solution code:

//Create a collection
ClearCollect(myCars21,
{Year: 2016, Make: "Toyota", Model: "Corolla"},
{Year: 2014, Make: "Honda", Model: "Civic" },
{Year: 2019, Make: "Toyota", Model: "Camry" },
{Year: 2018, Make: "Honda",Model: "Civic"},
{Year: 2018, Make: "Hyundai", Model: "Elantra"},
{Year: 2020, Make: "Honda", Model: "Accord"}
);

//Get middle rows code
ClearCollect(
    mySolution21b,
    LastN(FirstN(myCars21,5),3)
);