Creating Dice in Flexbox in CSS

Learn how to create dice in CSS using flexbox Dice created with flexbox in CSS First Face First face of the div Our first-face of the die will have one dot at the center. <div class=”dice first-face”> <span class=”dot”> </span> </div> Here, we have the dice– and dot-classed elements. Now we can add some CSS to the die. …

Find the difference between Dates in JavaScript

Learn how to find difference between two dates in JavaScript. Image from Lukas Blazek We learn about finding Number of Seconds , Number of Minutes , Number of hours , Number of days , Number of weeks , Number of months , Number of years between two dates. Let’s create two dates let d1 = Date.now(); let d2 = new Date(2019,5,22).getTime(); //Jun …

Implementing Linear Search in Javascript

Learn how the Linear search Algorithm works and how to implement it . Linear search is a Searching algorithm, which is used to check if an element is present in an array or list . It is also called Sequential search. A linear search sequentially search for the target element in the array. If it finds the …

Understanding Switch Statements in JavaScript

Image from negative space Whenever we are in situation of writing multiple if/else statement for a particular test case, then the multiple if/else statement can be replaced by switch statement. Syntax : switch(expression_or_value) {case expression_or_value : operation1 [break]; case expression_or_value : operation2 [break]; … default : default operation [break]; } // break is optional A switch statement …

Insert an element in specific index in JavaScript Array.

Learn how to insert an element in specific index in array. Image from unsplash (Zdennek) We have some in-built methods to add at elements at the beginning and end of the array. push(value) → Add an element to the end of the array. unshift(value) → Add an element to the beginning of an array. To add …

Master Destructing Values in JavaScript

Learn how to destructure array and object properties into variables in JavaScript. Image from Unsplash The destructing syntax allows us to extract multiple values based on the property name from objects or arrays. // Destructing arrayvar num = [1,2,3,4,5]; var [a, b] = num; console.log(a, b); //1,2 // Destructing Object var obj = { name : …

Essential DOM Operations with JavaScript

Learn about some basic but essential DOM methods in JavaScript Image by Pankaj Patel from Unsplash The below code is what we’ll use to access and manipulate with our JavaScript DOM methods: <div id=”parent”> <div class=”child one”> < /div> <div class=”child children second”> < /div> <div class=”child third”> < /div></div> Select and element by id. It …

An Overview of Array Methods in JavaScript

Learn about how to manipulate arrays in JavaScript Image by PaweĹ‚ CzerwiĹ„ski from Unsplash Let’s create an array: var numbers = [1,2,3,4,5] Array elements are accessed using an index. The index starts from 0 . So if we want to access the first element, then we need to access using index 0. numbers[0] // 1 numbers[3] // …

Console cheat sheet for JavaScript developers

Learn how to use the browser console effectively for debugging Image by Ilya Pavlov from Unsplash You can open console by using: Chrome → Ctrl Shift J (on Windows) or Cmd Option J (on Mac) Safari → Option-Cmd-C The console object provides access to the browser’s debugging console. The console object present in the global scope. …

Short intro about string functions in JavaScript

Learn about available JavaScript string functions. Image taken from unsplash String Properties 1.length var str = “Jagathish”;str.length; //9 –> returns the length of the string Functions toUpperCase() –> returns the new string in uppercase format of source string var str = “Jagathish”; var str2 = str.toUpperCase(); console.log(str);//Jagathish console.log(str2);//JAGATHISH 2.toLowerCase() –> returns the new string in lowercase …

Design a site like this with WordPress.com
Get started