Skip to content

Challenge (Adjust the Tone of a Color): Use computed styles for test or fix regex #45859

@lasjorg

Description

@lasjorg

Instead of using a regex maybe we should just check the computed styles?

background-color: hsl(180, 80%, 25%);

// $0 is the nav element
getComputedStyle($0).backgroundColor

'rgb(13, 115, 115)'

I realize doing so will technically allow users to pass the test without using the hsl() function, but I doubt people will convert the HSL value to hex or RGB and submit that.

Or, we can trim the code of whitespace and/or allow for spaces in the regex.


Forum thread: https://forum.freecodecamp.org/t/about-your-answer-checking-algorithm/507093

Challenge: https://www.freecodecamp.org/learn/responsive-web-design/applied-visual-design/adjust-the-tone-of-a-color

Test: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/01-responsive-web-design/applied-visual-design/adjust-the-tone-of-a-color.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedOpen for all. You do not need permission to work on these.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions