I am working with an array of objects that looks like this:
let obj = [
{ name: "Qwerty1", status: "Development" },
{ name: "Qwerty2", status: "Development" },
{ name: "Qwerty3", status: "Staging" },
{ name: "Qwerty4", status: "Production" },
{ name: "Qwerty5", status: "Production" }
]
In need of creating a function
getList(status) {
}
When calling this function, I will specify a status parameter such as "Development", "Stating", or "Production"
If I input "Production" to this function, it is expected to return an array containing all the objects with status: "Production", along with objects having statuses "Staging" and "Development"
For "Staging" status, the function should provide an array including all objects marked as "Staging" as well as those labeled "Development"
If given "Development" as the status, only objects with "Development" status must be returned
The order of priority is Production -> Staging -> Development ("Production" includes "Staging", "Staging" includes "Development")
Please keep in mind that the object cannot be altered as it originates from an API.