Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lecture/4-lists-input/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const generatePhoneNumber = () => `${rand(999, 100)}-${rand(999, 100)}-${rand(99
const createContact = () => ({name: generateName(), phone: generatePhoneNumber()})

// compare two contacts for alphabetizing
export const compareNames = (contact1, contact2) => contact1.name > contact2.name
export const compareNames = (contact1, contact2) => {
if (contact1.name < contact2.name) return -1
if (contact1.name > contact2.name) return 1
return 0
}

// add keys to based on index
const addKeys = (val, key) => ({key, ...val})
Expand Down