Draft

Simplified object comparison

129 of 130Katbow

Description:

This is a simplified version of Deep comparison of objects.

It's not easy to compare objects in JavaScript. Even two objects with the same properties and values will be considered different.

{a: 1, b: 2} === {a: 1, b: 2}
// false

Your task is to create a function, compareObjects(objectA, objectB), which compares 2 objects. The parameters will always be objects, and will not contain other objects or arrays, just strings and numbers. It will return true if the objects are the same, and false if they are not.

If both objects have the same values in a different order, they are considered the same. e.g.

compareObjects({a: "bc", d: "ef"}, {d: "ef", a: "bc"})
// true

NB: The JSON.stringify method is invalid.

Fundamentals

More By Author:

Check out these other kata created by Katbow

Stats:

CreatedNov 30, 2015
Warriors Trained292
Total Skips50
Total Code Submissions874
Total Times Completed130
JavaScript Completions129
CoffeeScript Completions6
Total Stars7
% of votes with a positive feedback rating80% of 72
Total "Very Satisfied" Votes51
Total "Somewhat Satisfied" Votes13
Total "Not Satisfied" Votes8
Total Rank Assessments63
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Katbow Avatar
  • gperales Avatar
Ad