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

coding exercise answers #2419

Merged
merged 3 commits into from Mar 28, 2024
Merged

Conversation

CptHappyHands
Copy link
Contributor

Looks like my linter changed a lot of the " to ' and vice versa. But besides that figure I would provide an explanation on what I did:

I only saw 3 lodash functions in that particular file. 

In this one, declared a new const and made it equal to everything but .dropdown from the original. This allowed me to declare another const, value, and check if .dropdown exists. If it does, great, it will equal .value, otherwise it'll equal 'all'.

                // return window.lodash.get(window.Typeahead['.js-typeahead-location_grid'].filters.dropdown, 'value', 'all')
                const { dropdown } =
                  window.Typeahead[".js-typeahead-location_grid"].filters;
                const value = dropdown?.value ?? "all";
                return value;

In this case, I used the .sort function. This will check the start_date property in descending order.

  // list = window.lodash.orderBy( list, [ "start_date" ], "desc")
  list.sort((a, b) => new Date(b.start_date) - new Date(a.start_date));

Here, I declared a new const, color, get the same info that the lodash was getting previously, and use it to set the background-color. 

    const color =
      window.wpApiSettingsPage?.workload_status_options?.[name]?.color;
    selected.css("background-color", color);
    // selected.css('background-color', window.lodash.get(window.wpApiSettingsPage, `workload_status_options.${name}.color`))

@corsacca
Copy link
Member

This looks great @CptHappyHands, thank you!
Would you be willing to resubmit the PR without the linting changes?

@CptHappyHands
Copy link
Contributor Author

This looks great @CptHappyHands, thank you! Would you be willing to resubmit the PR without the linting changes?

Thanks for checking that. I believe I got all of the linting changes reverted. Let me know if there is anything else I missed

@corsacca corsacca merged commit aa75d96 into DiscipleTools:develop Mar 28, 2024
2 checks passed
@corsacca
Copy link
Member

Thank you @CptHappyHands !

@corsacca corsacca linked an issue Apr 1, 2024 that may be closed by this pull request
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.

Replace lodoash functions with es6 ones
2 participants