UNPKG

@samnarduzzi/lotide

Version:

Lotide proejct containf files, test code files, index, and descriptions for all files

28 lines (25 loc) 632 B
const assertEqual = function(actual, expected) { if (actual === expected) { console.log(`Assertion passed: ${actual} === ${expected}`); } else { console.log(`Assertion failed: ${actual} !== ${expected}`); } }; const findKey = function(object, callback) { for (const item in object) { if (callback(object[item])) { return item; } } }; const list = { "Blue Hill": { stars: 1 }, "Akaleri": { stars: 3 }, "noma": { stars: 2 }, "elBulli": { stars: 3 }, "Ora": { stars: 2 }, "Akelarre": { stars: 3 } }; const result = findKey(list, x => x.stars === 2); console.log(result); // returns "noma"