-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: array loop to Array.forEach #19
Conversation
initially, I wanted to const result = languages.map(...) but I don't know exactly how to return object |
The following is my own opinion. |
I know that we can assign from an array to an object by using Array#reduce(). |
I see. btw, the first case doesn't need to break a loop, only skip it, so I can add a check, languages.forEach(lang => {
Object.keys(data[lang]).forEach(key => {
if (data[lang] && !Object.prototype.hasOwnProperty.call(result, key)) {
result[key] = data[lang][key];
}
}); wouldn't |
@curbengh Your opinion is correct. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
added another check. |
No description provided.