1/12/2024 0 Comments Subnetcalc inline![]() ![]() As always, I want to stress that there are an infinity of correct solutions to any programming challenge, so, if your code works, then it’s just as correct as mine! The challenge was to write a function to find all links in a page, check each to see if it’s internal to the site, or external, and if it’s external, to transform the link to have a target of _blank, a rel of noopener, and to inject an icon after the image to show that it will open in a new window/tab.īelow is my solution. You can also Download the MP3 Solution to Instalment 23’s Challengeīefore we get stuck into this instalment’s new content, let’s look at a solution to the challenge set at the end of the previous instalment. ![]() Listen Along: Chit Chat Across the Pond Episode 461 Your browser does not support HTML 5 audio □ The examples assume you’ll save the files within the zip in a folder named pbs24 in the document root of your local web server. The sample files used in this instalment, as well as some needed libraries, can be downloaded as a ZIP file here or here on GitHub. While we’re at it we’ll also add in some extra functionality to make its behaviour more customisable, and hence, more useful to more people. We’ll learn to do this using the free and open source tool JSDoc.Īs a worked example, we’ll rewrite our link fixer as an easily reusable API. So we’ll also learn how to create great API documentation as you code. ![]() Reusable code without documentation is all but useless. You may decide to share that code with others, or you may not, but either way, it’s in your interest to write it using some simple best practices. When you solve a problem that you know you’ll need to solve again, it’s worth putting in a little extra effort to make your code as easy to reuse as possible. In this instalment we’ll take our JavaScript skill up a level, learning how to write code that is designed to be reused by ourselves or by others. View on GitHub PBS 24 of x – Creating a JavaScript API ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |