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

James Walsh
James Walsh
7,377 Points

Feedback Appreciated

Hey guys, Can you check out this ? Just practicing some basic jQuery animations. I was wondering if there was an easier way to code this ? Thanks in advance for any feedback!

https://codepen.io/Room854/pen/zawqGj?editors=1000

2 Answers

Steven Parker
Steven Parker
231,198 Points

You can omit the creation of variables for things that will only be used once, and apply the method directly to the selector. And an arrow function can make the callback definition more compact. For example:

$('.circleThree').on('click', _=> $cardBox.slideToggle());

And here's what MDN says about the <xmp> tag:

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Also, were you aware that there is also a "slideToggle" function?

James Walsh
James Walsh
7,377 Points

Hey Stephen, thank you for the feedback, i don't think the jQuery basics course has covered arrow functions, but i vould be wrong. I did learn about them in the JavaScript basics though so i have an understanding on how they work. I will rewrite it using them. No, i wasnt aware that there was a slideToggle function. I think i need to do some research and more playing around to familiarize myself more with other functions and learn more outside of what the course has thought me. I will post an updated one in a couple of days and hopefully it'll be compact and some new features. Thanks for the tips and feedback, its much appreciated