Another question! (I only changed the functions.js file.)
First I did the solution below...is it good?
export const getLocale = (user, known) => {
if (user.locale == 'en' || user.locale == 'ru' || user.locale == 'es' || user.locale == 'it' || user.locale == 'fr') {
return user.locale;
} else {
return 'en';
}
}
Then I thought that there must be a better way to do this, in case the string was much bigger!
After some research I came up with the solution, below...is it good?
export const getLocale = (user, known) => {
const result = known.find(element => element == user.locale);
if (result == user.locale) {
return user.locale;
} else {
return 'en';
}
}