Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addressBook(arr) {
- let addressbook = {};
- for (let line of arr) {
- let [name, address] = line.split(':');
- addressbook[name] = address;
- }
- let data = Object.entries(addressbook);
- data.sort((a, b) => a[0].localeCompare(b[0]));
- for (let [name, address] of data) {
- console.log(`${name} -> ${address}`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement