React Native

const NUM_CONTACTS = 1000

const firstNames = [
‘Emma’,’Noah’,’Olivia’,’Liam’,’Ava’,’William’,’Sophia’,’Mason’,’Isabella’,
‘James’,’Mia’,’Benjamin’,’Charlotte’,’Jacob’,’Abigail’,’Michael’,’Emily’,
‘Elijah’,’Harper’,’Ethan’,’Amelia’,’Alexander’,’Evelyn’,’Oliver’,’Elizabeth’,
‘Daniel’,’Sofia’,’Lucas’,’Madison’,’Matthew’,’Avery’,’Aiden’,’Ella’,’Jackson’,
‘Scarlett’,’Logan’,’Grace’,’David’,’Chloe’,’Joseph’,’Victoria’,’Samuel’,’Riley’,
‘Henry’,’Aria’,’Owen’,’Lily’,’Sebastian’,’Aubrey’,’Gabriel’,’Zoey’,’Carter’,
‘Penelope’,’Jayden’,’Lillian’,’John’,’Addison’,’Luke’,’Layla’,’Anthony’,
‘Natalie’,’Isaac’,’Camila’,’Dylan’,’Hannah’,’Wyatt’,’Brooklyn’,’Andrew’,’Zoe’,
‘Joshua’,’Nora’,’Christopher’,’Leah’,’Grayson’,’Savannah’,’Jack’,’Audrey’,
‘Julian’,’Claire’,’Ryan’,’Eleanor’,’Jaxon’,’Skylar’,’Levi’,’Ellie’,’Nathan’,
‘Samantha’,’Caleb’,’Stella’,’Hunter’,’Paisley’,’Christian’,’Violet’,’Isaiah’,
‘Mila’,’Thomas’,’Allison’,’Aaron’,’Alexa’,’Lincoln’]

const lastNames = [
‘Smith’,’Jones’,’Brown’,’Johnson’,’Williams’,’Miller’,’Taylor’,’Wilson’,’Davis’,
‘White’,’Clark’,’Hall’,’Thomas’,’Thompson’,’Moore’,’Hill’,’Walker’,’Anderson’,
‘Wright’,’Martin’,’Wood’,’Allen’,’Robinson’,’Lewis’,’Scott’,’Young’,’Jackson’,
‘Adams’,’Tryniski’,’Green’,’Evans’,’King’,’Baker’,’John’,’Harris’,’Roberts’,
‘Campbell’,’James’,’Stewart’,’Lee’,’County’,’Turner’,’Parker’,’Cook’,’Mc’,
‘Edwards’,’Morris’,’Mitchell’,’Bell’,’Ward’,’Watson’,’Morgan’,’Davies’,’Cooper’,
‘Phillips’,’Rogers’,’Gray’,’Hughes’,’Harrison’,’Carter’,’Murphy’]

const getRandom = (min = 0, max) => Math.floor(Math.random() * (max – min + 1)) + min
// console.log(‘random 1 digit: ‘ + getRandom(0, 9))
// console.log(‘random 2 digits: ‘ + getRandom(10, 99))
// console.log(‘random 3 digits: ‘ + getRandom(100, 999))
// console.log(‘random 4 digits: ‘ + getRandom(1000, 9999))

const getRandomPhoneNumber = () =>
`${getRandom(100, 999)}-${getRandom(100, 999)}-${getRandom(1000, 9999)}`
// console.log(getRandomPhoneNumber())

const getRandomFirstName = () => firstNames[getRandom(firstNames.length – 1)]
// console.log(getRandomFirstName())

const getRandomLastName = () => lastNames[getRandom(lastNames.length – 1)]
// console.log(getRandomLastName())

const getRandomFullName = () => `${getRandomFirstName()} ${getRandomLastName()}`
// console.log(getRandomFullName())

const createContact = () => ({name: getRandomFullName(), phone: getRandomPhoneNumber()})
export const compareContacts = (contact1, contact2) => contact1.name > contact2.name

const addContactKey0 = (contact, key) => ({key: key, name: contact.name, phone: contact.phone})
const addContactKey = (contact, key) => ({key, …contact})
const addKey = (obj, key) => ({key, …obj})

Leave a Reply

Your email address will not be published. Required fields are marked *