0
array = ['data', 'category', 'hour'];

    object = {
        "status": {
            "type": "INFO",
            "messages": []
        },
        "data": {
            "id": 1,
            "tenant": "675832",
            "process": "6911d872-35f8-11ea-8697-001dd8b71c20",
            "category": "resquests"
"time": {
hour: "12",
minute: "30"
        }
    }

I need to check if object has keys with same value contained in array.

I tried split array by dot, and then filter both array and object but it fails.

const array = inputValue.split('.').map((item) => item);
André Castro
  • 1,527
  • 6
  • 33
  • 60

1 Answers1

-1

Do you need something like that?

console.log(arrayEquals(Object.keys(object),array)

with

function arrayEquals(a, b) {
  return Array.isArray(a) &&
    Array.isArray(b) &&
    a.length === b.length &&
    a.every((val, index) => val === b[index]);
}
Coder Sam
  • 1
  • 2