Skip to content
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

add my ugly solution. i think so, maybe not)) #2703

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GavriliukArtem
Copy link

Seems like it works

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Added comments to fix

// write code here
function transformState(state, action) {
for (const obj of action) {
// to iterate all objects in array.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing redundant comments

for (const [key, value] of Object.entries(obj)) {
// to iterate every object and split on keys and values.
//
// conditions check

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing redundant comments

}

if (obj[key] === obj.extraData) {
// add key and value to the object

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing redundant comments

}

if (obj[key] === obj.keysToRemove) {
// delete properies

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing redundant comments

@@ -4,8 +4,36 @@
* @param {Object} state
* @param {Object[]} actions
*/
function transformState(state, actions) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can place here a bunch of helper constants, for example:
const CLEAR = 'clear';
And use it instead of magic strings (a considered programming antipattern) in your code


if (obj[key] === obj.extraData) {
// add key and value to the object
for (const [k, v] of Object.entries(obj[key])) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using Object.assign instead of looping through every key

Copy link

@loralevitska loralevitska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

function transformState(state, action) {
const CLEAR = 'clear';

for (const obj of action) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructure obj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants