diff --git a/index.js b/index.js index 691020a..62c89f9 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ const where = (key = 'name', text = '') => { return all.find(element => element[key] === text) } - return all.find(element => element[key].toLowerCase() === text.toLowerCase()) + return all.find(element => (element[key] || '').toLowerCase() === text.toLowerCase()) } const getByName = text => where('name', text)