Write a function. Test real cases. Improve your solution.
Given tickets with an id string and status string, return an array of {status, ids} groups. Group order follows the first appearance of each status; ids inside each group follow input order. Status comparison is case-sensitive and every string, including an empty string or "__proto__", is valid. Preserve duplicate ids. Do not modify the input.
[
[
{
"id": "t1",
"status": "open"
},
{
"id": "t2",
"status": "closed"
},
{
"id": "t3",
"status": "open"
}
]
][
{
"status": "open",
"ids": [
"t1",
"t3"
]
},
{
"status": "closed",
"ids": [
"t2"
]
}
][ [] ]
[]
[
[
{
"id": "b",
"status": "waiting"
},
{
"id": "a",
"status": "open"
}
]
][
{
"status": "waiting",
"ids": [
"b"
]
},
{
"status": "open",
"ids": [
"a"
]
}
][
[
{
"id": "x",
"status": "__proto__"
},
{
"id": "y",
"status": "constructor"
},
{
"id": "z",
"status": "__proto__"
}
]
][
{
"status": "__proto__",
"ids": [
"x",
"z"
]
},
{
"status": "constructor",
"ids": [
"y"
]
}
][
[
{
"id": "a",
"status": "Open"
},
{
"id": "a",
"status": "open"
},
{
"id": "a",
"status": "Open"
}
]
][
{
"status": "Open",
"ids": [
"a",
"a"
]
},
{
"status": "open",
"ids": [
"a"
]
}
][
[
{
"id": "a",
"status": ""
},
{
"id": "b",
"status": "open"
},
{
"id": "c",
"status": ""
}
]
][
{
"status": "",
"ids": [
"a",
"c"
]
},
{
"status": "open",
"ids": [
"b"
]
}
][
[
{
"id": "a",
"status": "10"
},
{
"id": "b",
"status": "2"
},
{
"id": "c",
"status": "10"
}
]
][
{
"status": "10",
"ids": [
"a",
"c"
]
},
{
"status": "2",
"ids": [
"b"
]
}
]Your code runs in your browser. These exercises use synchronous JavaScript functions and built-in data types; DOM access, network requests, and npm imports are unavailable. Runs stop after about four seconds. Test results support self-study and don’t certify proficiency.