Posts

How to Make a Simple JavaScript Quiz

Image
"How do I make a JavaScript quiz?" is one of the most common questions asked by people learning web development, and for good reason. Quizzes are fun! They’re a great way of learning about new subjects, and they allow you to engage your audience with something fun and playful. Coding your own JavaScript quiz is also a fantastic learning exercise. It teaches you how to deal with events, manipulate the DOM, handle user input, give feedback to the user and keep track of their score (for example, using client-side storage). And when you have a basic quiz up and running, there are a whole bunch of possibilities to add more advanced functionality, such as pagination. I go into this at the end of the article . In this tutorial, I’ll walk you though creating a multi-step JavaScript quiz which you’ll be able to adapt to your needs and add to your own site. If you'd like to see what we'll be ending up with, you can skip ahead and see the working quiz . Things to Be Aware o...

Committing Changes to Your Codebase the Right Way

Image
The difference between a good and a bad commit can be huge. It's no fun having to ask your colleague — or your past self — what a particular change was about, or what the current state of things is. This article aims to provide a thorough guide to the best practices of software commits. Why Bother? If you’re already storing your projects on GitHub, you might assume the files are safe and that whenever you need to update code you'll pull the changes, and that’s enough. All of that might be true. But let's see what potential problems you can avoid by going the extra mile, and what additional benefits await if you do. No Man Is an Island, Either in Teams or Individually The reasoning above typically comes from a developer used to working alone. But the moment they need to share code with somebody else, we can expect that things are going to get messy and require a lot of explanation. Like, a lot . Remember that our work doesn't end at just writing code. We also need ...

Build a JavaScript Command Line Interface (CLI) with Node.js

Image
As great as Node.js is for “traditional” web applications, its potential uses are far broader. Microservices, REST APIs, tooling, working with the Internet of Things and even desktop applications: it’s got your back. Another area where Node.js is really useful is for building command-line applications — and that’s what we’re going to be doing in this article. We’re going to start by looking at a number of third-party packages designed to help work with the command line, then build a real-world example from scratch. What we’re going to build is a tool for initializing a Git repository. Sure, it’ll run git init under the hood, but it’ll do more than just that. It will also create a remote repository on GitHub right from the command line, allow the user to interactively create a .gitignore file, and finally perform an initial commit and push. As ever, the code accompanying this tutorial can be found on our GitHub repo . Why Build a Command-line Tool with Node.js? Before we dive in...

An Introduction to REST and RESTful APIs

Image
REST is an acronym for Representational State Transfer — an almost meaningless description of the most-used web service technology! REST is a way for two computer systems to communicate over HTTP in a similar way to web browsers and servers. Sharing data between two or more systems has always been a fundamental requirement of software development. For example, consider buying motor insurance. Your insurer must obtain information about you and your vehicle so they request data from car registration authorities, credit agencies, banks, and other systems. All this happens transparently in real time to determine whether a policy can be offered. REST Example Open the following link in your browser to request a random programming joke: https://official-joke-api.appspot.com/jokes/programming/random This is a public API implemented as RESTful web service (it follows REST conventions). Your browser will show an awful JSON-formatted programming joke, such as: [ { "id": 29...

Practical Ways to Advance Your TypeScript Skills

Image
As a programmer, it can feel like you know something well enough to be dangerous. For some situations, this is fine. All you need to know are these three methods in this programming language. Other times we want to develop expertise. In this article, we'll cover ways to advance your TypeScript skills to that next level. Below are various ways you can further your TypeScript abilities. These are in no particular order. Learn in Public One of my favorite movements is #LearnInPublic , which gained traction after Shawn Wang published a gist . When you tell others what you're doing, opportunities arise. These come in various forms. One form is connecting with others. You’re now viewed at as someone in the "TypeScript" space because people see you working with it. They may reach out for help. They may ask you questions. They may even ask you to do freelance work or content creation. You never know. Another door that it opens is the ability to teach others. Chances are...

5 jQuery.each() Function Examples

Image
This is an extensive overview of the jQuery.each() function — one of jQuery’s most important and most used functions. In this article, we’ll find out why and take a look at how you can use it. What is jQuery.each() jQuery’s each() function is used to loop through each element of the target jQuery object — an object that contains one or more DOM elements, and exposes all jQuery functions. It’s very useful for multi-element DOM manipulation, as well as iterating over arbitrary arrays and object properties. In addition to this function, jQuery provides a helper function with the same name that can be called without having previously selected or created any DOM elements. jQuery.each() Syntax Let’s see the different modes in action. The following example selects every <div> element on a web page and outputs the index and the ID of each of them: // DOM ELEMENTS $('div').each(function(index, value) { console.log(`div${index}: ${this.id}`); }); A possible output woul...

How to Tackle a Python Interview

Image
Have you cleared the first round of calls with the HR? Are you going for a Python interview in person? If you’re wondering what Python-related questions may be asked, this guide should be of help. In the first section, we’ll discuss a few questions about Python's philosophy — those that help you make decisions about the architecture of a project. In the next section, we cover questions related to the Pythonic way of programming — which may manifest in the form of review or finding the output of a code snippet. A word of caution before we start. This guide talks primarily about Python's built-in capabilities. The aim of this guide is to help you get up to speed with the inherent Python functionalities that enable quick development. So we won't be able to cover every question you may face from the various types of companies out there. Development in Python: Project Architecture What is Python? Why should you use Python? If you’re interviewing for a Python role, you shoul...