r/reviewmycode • • Jun 21 '17

Javascript [Javascript] - Online Store

Recently, I was given an interview assignment to create an online shopping store. I decided to build the store in React/Redux. The specifications were easy as they are basic functionalities. I didn't hear back so I was wondering what was wrong with my code.

Since it was a small project, I structured my code in Rails project directory.

https://github.com/lunzhang/store

2 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/lunny93 Aug 21 '17 edited Aug 21 '17

Thanks for your suggestions.

  1. Definitely should have written tests.
  2. I never knew that before but from now on I will start adding more spaces and empty lines.
  3. I thought that For-loops had better performance than built in functions, so I always used them instead.
  4. Thanks, I'll keep that in mind.
  5. My mistake :(.
  6. Thanks, I will.

Would you recommend any specific sources to javascript best practices guidelines?

I'm currently trying to follow airbnb's guidelines https://github.com/airbnb/javascript

Once again, thanks so much for your feedback!

2

u/violent-guitar Aug 23 '17

3. For-loops might have better performance for big data sets but performance is not a problem if you're handling an online store. You'll never have to deal with those amounts of data because that will not be a good user experience. You will for example implement pagination. That's why code readability > performance in this case.

Any guidelines are good as long as you are consistent (not any, but you get my point). Airbnb, google, standard. Whatever. It doesn't really matter. Try to write as much ES6 as possible I'd say, it is the future.

My tip for advancing your JS skills would be to get more involved in the great open source community on GitHub, for example. You could find a React component and contribute in form of issues, PRs or even write your own component. I do that and I've learned so much from it, it's also a nice feeling to co-operate with other coders.

Good luck!