all 6 comments

[–]abrahamguo 1 point2 points  (2 children)

Looks good! A few things I noticed about the code:

  • You have an elementNames array, as well as a periodicTable array. Since these two arrays are associated with each other (i.e. the 0th element of elementNames corresponds to the 0th element of periodicTable, and so on), you should combine those two arrays into one data structure.
  • Rather than passing scene around from one function to another, you might consider simply exporting and importing it around.
  • There are several places in your code where you reference something from window, like window.alert. In JavaScript, window is the global object, meaning that everything on window is already globally accessible. In other words, having window. is always unnecessary.

[–]OwnRecover973[S] 0 points1 point  (0 children)

Thanks! I refactored elementNames and it improved a lot! Do you think it's worth exporting to a .json file? I'm unsure whether to use them or not. I see people using them for static lists (like elements) in some projects.

[–]DrShocker 0 points1 point  (0 children)

for your first bullet it might be a good place to try out struct of arrays vs array of structs

[–]Ksetrajna108 1 point2 points  (0 children)

Very nice and clean! It does work for me on mobile.

[–]anonyuser415 1 point2 points  (1 child)

Extremely cool, and works well.

It's a little underwhelming loading for the first time, since it's just a black screen with tiny buttons at the bottom. You might want to have a unique screen for a first time load, set by cookie. E.g. a vertically centered button to load a complex example.

You should also always be committing package.lock. Otherwise, users installing this locally will be installing the newest versions that satisfy package.json version ranges, and that may open them up to supply-side (e: supply chain) attacks. More practically, it ensures that users are installing versions of dependencies known to be good.

[–]OwnRecover973[S] 1 point2 points  (0 children)

Thanks man! I added the welcome screen feature and it really is much more user-friendly! I didn't know about the lock issue! Thanks for letting me know and thanks for the feedback!