Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

All comments

  • Soraya 230

    @Sorpanda

    Submitted

    This is my first Javascript project. I watched some courses for Javascript, learning the basics. I haven't learned all of it yet, but I felt lost so I wanted to just do a challenge without having gone through all the material and see where it brought me... I figured out how to get the rating buttons to work and show the value in the text. There might be a better/simpler way, but this was done completely on my own so I left it this way.

    The showing and hiding of the 2 different elements (Survey and Thank you) after submitting was difficult. I searched the internet and found this on stack overflow, I did change the id names to apply to my code:

    /*

    if (document.getElementById('survey')) {

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

    It worked but I didn't fully understand it. After reading it over and over I think it means:

    if (document.getElementById('survey')) <-- this equals to true, so it runs the next if/else statement within its block. Does this if statement only run once when page is loaded? not after that?

    if (document.getElementById('survey').style.display == 'none') <-- this if statement equals to false, skipping the code in the if statement and going to else instead. The else conditions then only activate when clicking on the button.

    This code is supposed to be a toggle, if I would have had another button on the afterSubmit element I could click on that button and after clicking the button. The if statement: if (document.getElementById('survey').style.display == 'none') now equals to true and runs the code within, hiding the afterSubmit element and showing the survey again.

    Because I didn't need to toggle between the 2 elements I simplified my code, and it works!

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

    dia ♡ 200

    @diaasaur

    Posted

    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

    1
  • nanc 940

    @naiiiden

    Submitted

    Todo App

    #accessibility#sass/scss#animation

    1

    dia ♡ 200

    @diaasaur

    Posted

    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?

    1
  • dia ♡ 200

    @diaasaur

    Posted

    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!

    0
  • dia ♡ 200

    @diaasaur

    Posted

    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

    1