A settings page enables its Save button only when the edited settings differ from the saved ones. The settings are nested JSON values, and === on two objects only checks whether they are the same object.
Write deepEqual(a, b) that returns true when the two JSON values have the same contents: equal primitives (null, numbers, strings, booleans), arrays of the same length with deep-equal items in the same order, or objects with the same set of keys and deep-equal values (key order doesn't matter). An array never equals an object.
Input: a = {"theme":"dark","tabs":[1,2],"font":{"size":14}}, b = {"font":{"size":14},"tabs":[1,2],"theme":"dark"} Output: true
Same keys and values; the key order differs, which doesn't matter.
Input: a = {"tabs":[1,2]}, b = {"tabs":[2,1]} Output: false
Array order matters.
10^4 items in total and nesting up to 100 levels.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #739 Are Two Settings Equal?. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.