В библиотеке два словаря. В shelves ключ это номер полки, значение массив книг на ней. В authors ключ это название книги, значение её автор.
Напиши функцию shelvesWithAuthor(shelves, authors, author). Она возвращает массив полок, на которых стоит хотя бы одна книга этого автора. Порядок полок любой.
shelvesWithAuthor({ 1: ['Three Comrades'], 2: ['The Idiot'], 3: ['Arch of Triumph', 'Three Comrades'] }, { 'Three Comrades': 'Remarque', 'The Idiot': 'Dostoevsky', 'Arch of Triumph': 'Remarque' }, 'Remarque')Вернёт [ '1', '3' ]
shelvesWithAuthor({ 1: ['The Idiot'] }, { 'The Idiot': 'Dostoevsky' }, 'Remarque')Вернёт []
Спрашивали в T-Bank · Источник
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' ]Скрытые тесты запускаются по Submit.