Recent Posts
Coin Flip Simulator With Javascript And CSS Animations
In this tutorial, you will learn to build a small app to toss a coin using HTML, CSS, and Javascript. The possible outcomes after flipping a coin are either "Head" or "tail". The probability of getting head or tail is 50%.
Use Math.PI To Calculate Area And Circumference Of A Circle
The "Math.PI" property returns the PI "π" constant, approximately equal to 3.14159. For example, you can calculate the circumference and surface area of a circle using "Math.PI".
Check If A Function Exists Before Calling With The typeof Operator
If you are sharing scripts from different modules or you have a large codebase, you can use the `typeof` operator to check if a function exists.
Create A Toggle Button In Javascript To Manipulate The DOM With The toggle() Method
The "toggle()" is a method of the "DOMTokenList". It removes something like a "class" name from the list, and returns "false". If the "class" name does not exist, it will add it to the list and return "true".
Understand The Comparison Operators In Javascript And Write Logic Like A Pro
A comparison operator compares two values with each other, and returns a logical value such as "true" or "false". The operands can be "number", "string", "logical", or "object" values.
Using The Javascript fillRect() Method To Create An Interactive Keyboard Controlled Rectangle Inside A Canvas
The fillRect() method renders 2d context on HTML "canvas" element. You can create simple or complex shapes by defining ( x, y, width, height) on the canvas.
Using The Math.ceil() Function In Javascript To Round a Number Up
To round a number up in Javascript, you can use the Math.ceil() function.
Math.floor() Function in Javascript, Uses, Limitations, Type Coercion
The Math.floot() function Rounds a number down to its closest integer, for example, Math.floor(5.99) returns 5.
Truncate a String In Javascript With The slice(), substr() And substring() Methods
You can shorten a string and limit the character length of a sentence using the slice(), substr() And substring() methods.
Flattening Nested Arrays In Javascript With flat() Method
Learn how to flatten nested arrays with all the elements concatinated using the flat() method.