Guest User

Untitled

a guest
Oct 16th, 2019
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * @name Function with too many parameters
  3. * @description Functions with many parameters are hard to read and hard to use.
  4. */
  5.  
  6. function sendRecord(firstName, lastName, dateOfBirth, streetAddress, postCode, city, country, email, website) {
  7. sendResponse({
  8. name: lastName + ', ' + firstName,
  9. DOB: dateOfBirth,
  10. address: streetAddress + '\n' + postCode + ' ' + city + '\n' + country,
  11. email: email,
  12. url: website
  13. });
  14. }
  15.  
  16.  
  17. //better
  18. function sendRecord(record) {
  19. sendResponse({
  20. name: record.lastName + ', ' + record.firstName,
  21. DOB: record.dateOfBirth,
  22. address: record.streetAddress + '\n'
  23. + record.postCode + ' ' + record.city + '\n'
  24. + record.country,
  25. email: record.email,
  26. url: record.website
  27. });
  28. }
RAW Paste Data