Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Interacting with the DOM Responding to Events Functions as Parameters

Farai Tanekha
Farai Tanekha
5,500 Points

Indentation & differentiating between regular function and arrow function

Great presentation! I just thought there were 2 things that could be added to make it better:

  1. Include indentation withing the function body
  2. Make clear the difference between a regular anonymous function vs an (anonymous) arrow function, as some beginners watching the video may not be aware of this.

For example:

  • Anonymous regular function (declaration):

    function (){
    \s console.log("I am an anonymous function with clear indentation in my function body.")
    }
    
  • Arrow function

    ()=> {
    \s console.log("I am an arrow function with clear indentation in my function body.")
    }
    

Please, note that I have used the JS metacharacter \s to indicate space/ indentation as I couldn't find the right markdown for it.

1 Answer

Steven Parker
Steven Parker
229,745 Points

He had to insert new lines from the bottom to prevent the editor from auto-indenting!   :see_no_evil:

And spaces are not collapsed inside a Markdown code section. So you can just put the actual number of spaces that you want displayed.
For example:

  <-- two spaces
        <-- eight spaces