Modulo oblongata

The modulo (or modulus) operator % returns the remainder of a division operation. 3 % 0 === NaN (cannot divide by 0)3 % 1 === 0 (3 remainder 0)3 % 2 === 1 (1 remainder 1)3 % 3 === 0 (1 remainder 0)3 % 4 === 3 (0 remainder 3) A classic use case for … Read more

Declaring a function

To declare a function in JavaScript, use the function keyword, a function expression, or an arrow function. To use the function keyword to declare a function, simply precede the function name with the word function, then append the function name with a set of parentheses followed by a set of braces. To use a function … Read more

Reversing an array

To reverse the order of elements in an array in JavaScript, use the reverse() method. The reverse() method will swap the order of elements in an array such that the first will become the last and so forth. The reverse() method is an example of an in-place operation which means the original array is transformed … Read more

The ternary operator

The ternary operator evaluates a condition then returns one of two responses depending on whether the condition evaluates as true or false. The structure of the ternary operator is as follows: condition ? response if true : response if false The ternary operator can be used to assign a value to a variable depending on … Read more

Get the data type of a variable in JavaScript

To get the data type of a variable in JavaScript, use the typeof keyword before the variable name. The typeof keyword returns the data type of the variable or property that follows it. In JavaScript, an array is an object type, therefore the keyword typeof will return object for both arrays and traditional objects. A … Read more

Add custom CSS to your WordPress website

To add custom css, select the Appearance > Customize option from the admin dashboard, and then Additional CSS. Custom CSS is very useful for applying slight tweaks to the appearance of your website without having to edit any of the theme files. These custom rules are applied after the main CSS files of the theme … Read more

Create a seamless address bar display on mobile

To fill the top part of mobile displays with a custom color, insert the theme-color meta tag into your index.html document and set the content property to your chosen color. When viewing a website, the default behaviour of mobile displays is surround the address bar at the top of the screen with the browser default … Read more

Commenting your code

Comments provide useful context to your code so you and other developers can better understand the purpose of that code upon review. Comments can be used to provide information about a line of code, such as the intended function and possible inputs and outputs. Comments can also be used to hide code from being executed … Read more

Centering an element

To center an element, apply and margin of auto. Alternatively, use a display of flex, with content center-justified or grid, with content placed in the center. There are several ways to center an element using CSS, and the best method to use depends on the given context. The simplest way to center an element is … Read more

Categories CSS