Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 2 years ago

Vanilla CSS, JS

Dan•820
@Gitit2meBaby
A solution to the Space tourism multi-page website challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I have an issue with the Tech page, 50% of the time it works fine, For others I get a return of null and am not fetching the JSON data correctly. not sure why... I think I will watch the tutorial now to get a better handle on the correct methods to get this site looking and functioning properly.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Alexander Hergert•710
    @alexander-hergert
    Posted almost 2 years ago

    Hi Dan, good job on the project. To answer your questions:

    I do not see issues with fetching. That seems fine for me. The two issue you name if understand correctly is that switching between the objects in the technology page is not working correctly. It seems your event triggers when you click the h3 or the parent div element. My solution would be to lift up the data-set to the parent div like so:

    In your technology.html file at line 80:

    <div class="technology-toggles-container ">
        <div data-technology="Launch vehicle" class="technology-toggle-btn technology-toggle- 
          active">
            <h3 id="tech1">1</h3>
        </div>
        <div data-technology="Spaceport" class="technology-toggle-btn">
             <h3 id="tech2">2</h3>
        </div>
        <div data-technology="Space capsule" class="technology-toggle-btn">
             <h3 id="tech3">3</h3>
        </div>
    </div>
    

    Otherwise the div element will not have the infos when you click on it and the page is not changing.

    Another issue you have is the:

    script.js:53 Uncaught (in promise) TypeError: Cannot set properties of null (setting 'textContent')
        at updateDestination (script.js:53:42)
        at script.js:20:9
    

    This issue happens because your single script.js file is always trying to read elements which are not always in the document. If you switch the pages then some of the elements are always missing.

    You can help yourself if you wrap your functions into a try catch block so that the code does not break if you try to use properties of null or what I would advise is to use a different structure in first place.

    You could create a src folder and divide your script file into a script file for each page instead and link the correct file in the head. That should also avoid the error since the elements wich are missing will not be tried to selected or used.

    I hope this helps you a bit Dan. My advice is to make a different structure for your files in the next project, since its not common to have everything in one file. Practice this please :D Also make more use of Git and structure your project in small steps and commit them. This helps to understand how you developed your project and helps your to jump back to a working state in case the projects breaks.

    Best regards Alex

    Marked as helpful
  • Carlos Villarta•260
    @caloyv
    Posted almost 2 years ago

    Hi, I think I found the issue to your problem regarding to the tech page. Your data is not updating when you press the button because almost the whole button is covered by the parent <div class="technology-toggle-btn"> but the <h3> tag is so small. Your button changes state when you press the parent div but the data wont update if you miss the <h3> tag. Open the dev tools, enable the select element and hover to the buttons to verify it. Hope this helps :).

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord

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

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

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