Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function phoneBook(input){
- let mybook = [];
- let newbook = []
- input.forEach(line => {
- let [name,phone] = line.split(" ");
- let book = {
- [name]: phone,
- }
- mybook.push(book);
- });
- for(let element of mybook) {
- let el= Object.entries(element)
- newbook.push(el)
- }
- newbook.sort((a,b) => a[0][0].localeCompare(b[0][0])).map(a=> console.log(`${a[0][0]}`))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement