<script> const users = { '727219': { id: 100 }, '727220': { id: 101 } } function userById(id, users) { for (user in users) { if (users[user].id === id) return { id, user } } } console.log(userById(100, users)) </script>