Created
December 3, 2021 14:43
-
-
Save jpsc/26a73ce007a1b5129dbfcab81e59f029 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// // i18n is an object with the translations for that locale | |
// const i18n = { | |
// personal: { | |
// gender: { | |
// { male: 'Male' }, | |
// //etc | |
// } | |
// }, | |
// } | |
export translation(i18n, key) { | |
return i18n[key]; | |
} | |
export getGender(gender) { | |
return translation(i18n, 'gender', gender); | |
} | |
export getNameWithGender(personalData){ | |
return `${getGender(personalData['gender']) personalData['firstName'] personalData['lastName']}` | |
} | |
// If you want to test if the name with the prefix greeting you can import getNameWithGender and tested without needing the component | |
import { getNameWithGender } from './data-separation.mjs' | |
const data = { | |
gender: 'Female', | |
firstName: 'Claudia', | |
lastName: 'Hemling' | |
} | |
assert(getNameWithGender(data)).equals(' Mrs Claudia Hemling'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment