A library has two dictionaries. In shelves the key is a shelf number and the value is an array of books on it. In authors the key is a book title and the value is its author.
Write a function shelvesWithAuthor(shelves, authors, author). It returns an array of the shelves that have at least one book by that author. Any order of shelves is fine.
shelvesWithAuthor({ 1: ['Three Comrades'], 2: ['The Idiot'], 3: ['Arch of Triumph', 'Three Comrades'] }, { 'Three Comrades': 'Remarque', 'The Idiot': 'Dostoevsky', 'Arch of Triumph': 'Remarque' }, 'Remarque')Returns [ '1', '3' ]
shelvesWithAuthor({ 1: ['The Idiot'] }, { 'The Idiot': 'Dostoevsky' }, 'Remarque')Returns []
Asked at T-Bank · Source
shelvesWithAuthor({ '1': [ 'Three Comrades' ], '2': [ 'The Idiot' ], '3': [ 'Arch of Triumph', 'Three Comrades' ] }, { 'Three Comrades': 'Remarque', 'Arch of Triumph': 'Remarque', 'All Quiet on the Western Front': 'Remarque', 'The Idiot': 'Dostoevsky', 'The Master and Margarita': 'Bulgakov', 'Heart of a Dog': 'Bulgakov' }, 'Remarque')[ '1', '3' ]shelvesWithAuthor({ '1': [ 'The Idiot' ] }, { 'Three Comrades': 'Remarque', 'Arch of Triumph': 'Remarque', 'All Quiet on the Western Front': 'Remarque', 'The Idiot': 'Dostoevsky', 'The Master and Margarita': 'Bulgakov', 'Heart of a Dog': 'Bulgakov' }, 'Remarque')[]shelvesWithAuthor({ '1': [ 'Heart of a Dog', 'The Idiot' ], '2': [ 'Three Comrades' ], '3': [ 'The Master and Margarita' ] }, { 'Three Comrades': 'Remarque', 'Arch of Triumph': 'Remarque', 'All Quiet on the Western Front': 'Remarque', 'The Idiot': 'Dostoevsky', 'The Master and Margarita': 'Bulgakov', 'Heart of a Dog': 'Bulgakov' }, 'Bulgakov')[ '1', '3' ]Hidden tests run on Submit.