After my recent schooling in JavaScript, I was very excited to take on a minor work project that let me flex my new vocabulary and solve an issue for our librarians.
My Journey
Platform: Springshare's LibGuides
Problem: Their A-Z list needs to display a list of specific databases according to type and sort those combined lists alphabetically.
Solution: Access LibGuides A-Z API. Target the desired databases by ID. Append a sorted list into a pre-constructed div.
Springshare got me started by providing the API information and offering some iterative code. This was my jumping off point:
I refactored their code, then set out to figure out why simply tacking on .sort() to the end of .append(list) was not working for me. Half a day later, it occurred to me that I needed to be targeting the list items themselves, rather than the div that held that list! After spending much time on StackOverflow and several developers' blogs, here is my final code:
Of course, that was AFTER I refactored with some ES6 using the arrow function as my sort function. But after getting nothing in IE11, it occurred to me to check if that functionality was available for that browser (caniuse.com). Nope. Back to the regular old function expression! But I was satisfied that I had learned to use the arrow function, and will keep that close by when all browsers (ahem, Microsoft...) catch up.
In Conclusion
I'm on my way to being more proficient in JavaScript! I'm comfortable refactoring code, searching for methods that work, and using the ternary operator. The above code is a beginner's solution, but a good start to getting what we wanted. And I'm excited to be a part of that solution. Bonus: I wrote a bookmarklet during this development process to count the number of database links that were coming through, so I could verify we were filtering the right ones.
Thanks, FreeCodeCamp, for pushing me forward, teaching me some basics, and giving me the confidence to offer solutions.