Skip to content
  • Unlock Pro
  • Log in with GitHub
Profile
OverviewSolutions
8
Comments
4
dia ♡
@diaasaur

All comments

  • Soraya•230
    @Sorpanda
    Submitted about 2 years ago

    Interactive Rating Component (HTML CSS Javascript)

    1
    dia ♡•200
    @diaasaur
    Posted about 2 years ago

    Hi Soraya! Great job on your first JS challenge <3

    The showing and hiding of the 2 different elements (Survey and Thank you) after submitting was difficult

    The task of showing and hiding the two elements (Survey and Thank you) after submitting can be challenging. Let's break down what you did to achieve this:

    1. You have two articles, survey and afterSubmit, which are initially arranged one after another in the DOM/HTML.
    2. Initially, to hide the afterSubmit element, you added the CSS rule display: none.
    3. You used an onclick event handler function called switchVisible to make survey invisible and afterSubmit visibile. This function performs two actions: a. It changes the display property of the survey from its default value display: block to display: none, effectively hiding it. b. It changes the display property of the afterSubmit element from display: none to display: block, making it visible.

    you can safely change switchVisible from:

    function switchVisible() {
    if (document.getElementById('survey').style.display == 'none') {
    } else {
    document.getElementById('survey').style.display = 'none';
    document.getElementById('afterSubmit').style.display = 'block';
    }
    }
    

    where if (document.getElementById('survey').style.display == 'none') {} is redundant because survey IS visible if you are able to see the survey and the submit button

    to (removing the redundant if statement):

    function switchVisible() {
    document.getElementById('survey').style.display = 'none';
    document.getElementById('afterSubmit').style.display = 'block';
    }
    

    if (document.getElementById('survey')) <-- this equals to true, so it runs the next if/else statement within its block.

    Yes! you are on the right track!

    When encountering an if statement, the condition inside the parentheses is evaluated. In this case, document.getElementById('survey') retrieves the HTML element with the ID survey. If the element exists, it is considered a 'truthy' value, and JavaScript coerces it to true. If the element does not exist (i.e., it is null), it is considered a 'falsy' value, and JavaScript coerces it to false.

    The if statement does not automatically run again after the page loads unless explicitly triggered by an event or condition.

    Please let me now if what I'm saying is wrong, and also what are potential other ways to approach this?

    • You can use a .hidden utility class and add/remove it on an element using document.getElementById('myElement').classList.add('myClass') or document.getElementById('myElement').classList.remove('myClass') classList property MDN (BTW classList can help you add a .selected class on the clicked rating!)
    .hidden {
    display: none;
    }
    
    • Rather than using inline onclick handlers, you can attach event listeners to the submit button using JavaScript. This allows for more flexibility and separation of concerns.
    Marked as helpful
  • nanc•940
    @naiiiden
    Submitted about 2 years ago

    Todo App

    #accessibility#sass/scss#animation
    1
    dia ♡•200
    @diaasaur
    Posted about 2 years ago

    Hey nanc =) really enjoyed the transitions you added for adding/deleting todos! I noticed that when I remove the last todo, empty list SVG becomes visible before todo transitions out. Is there a way to delay showing the SVG until the transition is fully completed?

  • nanc•940
    @naiiiden
    Submitted about 2 years ago

    Age Calculator App

    #accessibility#animation
    1
    dia ♡•200
    @diaasaur
    Posted about 2 years ago

    Hi nanc!

    I found a small bug in years, months days. Steps to reproduce:

    • Give input day 19 month 2 year 2002
    • Result is, 21 years 2 months -13 days instead of 21 years 1 months 18 days

    Apart from that your solution looks nice and clean ✨ and love that you took care of all the edge cases for form validation!

  • Matej Kukolik•40
    @dalinec
    Submitted almost 3 years ago

    Product preview card component

    1
    dia ♡•200
    @diaasaur
    Posted almost 3 years ago

    Hey Matej, good job on completing your first challenge!

    You can make the button look cleaner by:

    • Making the icon and text center aligned(vertical + horizontal) and adding a little more gap between them. Like this:
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5em; 
    
    • Applying the specified font-family and increasing the font size.
    Marked as helpful
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub