Advertisement
Liliana797979

Address book - fundamentals

Sep 5th, 2021
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let addressBook = {};
  3.     for (let line of input) {
  4.        
  5.         let [name, address] = line.split(":");
  6.         addressBook[name] = address;
  7.     }
  8.     let sorted = Object.entries(addressBook);
  9.     sorted.sort((a,b) => a[0] .localeCompare(b[0]));
  10. }
  11.  for (let key in sorted) {
  12.     console.log(`${key} -> ${sorted[key]}`);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement