Skip to content
  • Unlock Pro
  • Log in with GitHub
Profile
OverviewSolutions
1
Comments
1

Cyrus

@ohCyrusSweden10 points

Current language / technologies I use: 📑 HTML ☕ Javascript 🎨 CSS ⚡ Tailwind CSS 🐍 Python

Latest solutions

  • 🎨 Tailwind CSS - NFT Product Showcase Page

    #tailwind-css

    Cyrus•10
    Submitted over 3 years ago

    1 comment

Latest comments

  • Mo•840
    @MohamedAridah
    Submitted over 3 years ago

    URL shortening API landing page using SASS and JavaScript

    #fetch#sass/scss
    1
    Cyrus•10
    @ohCyrus
    Posted over 3 years ago

    You could make your code more readable by using guarding clause in JavaScript. It will avoid nested if ... else statements and makes code cleaner to read in a function.

    function exampleFunction(arg) {
        if (!arg > someExpressionHere) return;
       // ... Do something otherwise
    }
    

    In my opinion, a function should only do 1 thing. And it's better than 1 function that do all the work. By splitting up functions in parts, it will make the project more easier to maintain than your current code. Avoid also NESTED functions.

    Just write it out in the global scope so other function can reuse it. Or simply use ES6 classes if you like structured code 😉 Example on nested fns:

    function doSomething(arg, arg2) {
       // ...
      
      // Nested
      function anotherFunction(arg) {
        // ... Do something
      }
    } 
    

    Instead:

    // Pass in all required args for the function to work
    function anotherFunction(arg, arg) {
        // ... Do something
    }
    
    function doSomething(arg, arg2) {
       // ...
      
      // Pass in required arguments
      anotherFunction(arg, arg2);
    }
    
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