Write a function. Test real cases. Improve your solution.
Given notifications with an id string and a read boolean, return {unreadIds: [...], readIds: [...]}. Put each notification id in the matching array while keeping its order within that group. Every notification counts, even if ids repeat. Other fields are irrelevant. The input always contains valid notification objects and must remain unchanged.
[
[
{
"id": "n1",
"read": false
},
{
"id": "n2",
"read": true
},
{
"id": "n3",
"read": false
}
]
]{
"unreadIds": [
"n1",
"n3"
],
"readIds": [
"n2"
]
}[ [] ]
{
"unreadIds": [],
"readIds": []
}[
[
{
"id": "a",
"read": true
},
{
"id": "b",
"read": true
}
]
]{
"unreadIds": [],
"readIds": [
"a",
"b"
]
}[
[
{
"id": "b",
"read": false
},
{
"id": "a",
"read": false
}
]
]{
"unreadIds": [
"b",
"a"
],
"readIds": []
}[
[
{
"id": "x",
"read": false
},
{
"id": "x",
"read": false
},
{
"id": "x",
"read": true
}
]
]{
"unreadIds": [
"x",
"x"
],
"readIds": [
"x"
]
}[
[
{
"id": "alert",
"read": false,
"message": "Deploy failed",
"priority": 3
}
]
]{
"unreadIds": [
"alert"
],
"readIds": []
}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.