/qa_restore-names

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

QA Restore names (uk)

The database failed. Some users lost values from the firstName field, but user object has a fullName field, so we can restore firstName.

Write tests for restoreNames function, that takes an array of users and set correct firstName to users who do not have it or is equal to undefined. You should not return anything from the function.

Example:

const users = [
  {
    firstName: undefined,
    lastName: 'Holy',
    fullName: 'Jack Holy',
  },
  {
    lastName: 'Adams',
    fullName: 'Mike Adams',
  },
];

restoreNames(users);

// users === [
  {
    firstName: 'Jack',
    lastName: 'Holy',
    fullName: 'Jack Holy',
  },
  {
    firstName: 'Mike',
    lastName: 'Adams',
    fullName: 'Mike Adams',
  },
];