Skip to content

Instantly share code, notes, and snippets.

@iancover
Last active January 18, 2022 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iancover/be4009f9829fce5cf2864c55b5e0417c to your computer and use it in GitHub Desktop.
Save iancover/be4009f9829fce5cf2864c55b5e0417c to your computer and use it in GitHub Desktop.
Thinkful JS Object exercise
var obj1 = {
key1: 1,
key2: 'Value2',
key3: 3,
key4: 'Value4'
}
var obj2 = {
key1: 1,
key2: 'Value2',
key3: 'Value3'
}
var someKeys = [
'id', 'name', 'age', 'city'
];
function validateKeys(obj,someKeys) {
if (Object.keys(obj).length !== someKeys.length) {
return false;
}
for (var i=0; i<someKeys; i++) {
if (Object.keys(obj) !== someKeys[i]);
return false;
}
return true;
}
console.log(validateKeys(obj1,someKeys));
console.log(validateKeys(obj2,someKeys));
@iancover
Copy link
Author

iancover commented May 2, 2017

Line 25: can't figure out how I got the loop to work written with 'i<someKeys' and not 'i<someKeys.length'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment