Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
Encrypting a string based on an algorithm in JavaScript
We are required to write a JavaScript function that takes in a string and encrypts it based on the following algorithm: The string contains only space separated words. We need to encrypt each word in the string using the following rules: The first letter needs to be converted to its ASCII code. The second letter needs to be switched with the last letter. ...
Read MoreUsing operations to produce desired results in JavaScript
We are required to write a JavaScript function that takes in an array of exactly 4 numbers, arr, as the first argument and a target as the second argument. Our function needs to determine whether the numbers in the array arr can be operated through *, /, +, -, (, ) to get a value equal to the target. Problem Example For example, if the input to the function is: Input const arr = [5, 3, 2, 1]; const target = 4; Output true Output Explanation Because ...
Read MoreHow to access HTML elements in JavaScript?
In JavaScript, accessing HTML elements is fundamental for creating dynamic web pages. The Document Object Model (DOM) provides several methods to select and manipulate HTML elements based on different criteria. Get HTML element by Id Get HTML element by className Get HTML element by Name Get HTML element by tagName Get HTML element by CSS Selector Get HTML element by Id The getElementById() method retrieves a single element using its unique ID attribute. This is the most efficient way to ...
Read MoreHow to set the position of a Triangle from left using FabricJS?
In this tutorial, we are going to learn how to set the position of a Triangle from the left using FabricJS. Triangle is one of the various shapes provided by FabricJS. In order to create a triangle, we will have to create an instance of fabric.Triangle class and add it to the canvas. We can manipulate a triangle object by changing its position, opacity, stroke and also its dimension. The position from left can be changed by using the left property. Syntax new fabric.Triangle({ left: Number ...
Read MoreHow to render a list without rendering an engine in JavaScript?
In this tutorial, we'll explore how to render a list dynamically in JavaScript without using a rendering engine like React or Vue. We'll demonstrate various methods to create lists directly in the DOM using vanilla JavaScript and jQuery. Using Array.forEach() Method The Array.forEach() method iterates over an array and executes a callback function for each element. This is ideal for creating list items dynamically. forEach Example Rendering the list using the Array.forEach() Method ...
Read MoreCreate a Calculator using HTML, CSS, and JavaScript
To create a calculator using HTML, CSS, and JavaScript, we need to have basic understanding of working of HTML, CSS and JavaScript. Calculator is a simple tool which performs basic arithmetic calculations like Addition, Subtraction, Multiplication and Division. In this article, we are going to discuss how to create a Calculator using HTML, CSS, and JavaScript. Usually, if we observe any real-time calculator we know that it has: A grid of numbers (0-9 and 00). Basic arithmetic operators (+, -, /, x, %). Some symbols for ...
Read MoreHow to change the font style of Text using FabricJS?
In this tutorial, we are going to learn about how to change the font style in Text object using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. We can change the font style by using the fontStyle property. Syntax new fabric.Text(text: String, { fontStyle: String }: Object) Parameters ...
Read MoreHow to access an object having spaces in the object's key using JavaScript?
When object keys contain spaces, you cannot use dot notation to access them. Instead, you must use bracket notation with quotes around the key name. The Problem with Spaces in Keys Dot notation requires valid JavaScript identifiers, which cannot contain spaces. Keys with spaces need bracket notation. const person = { 'first name': 'John', 'last name': 'Doe', age: 30 }; // This won't work - syntax error // console.log(person.first name); // This works - bracket notation console.log(person['first name']); console.log(person['last name']); ...
Read MoreSplitting an array into chunks in JavaScript
In JavaScript, splitting an array into smaller chunks of equal size is a common operation. This article covers multiple approaches to divide array elements into n-sized chunks effectively. Input and Output Example: Consider an array with elements [10, 20, 30, 40] and chunk size of 2: Input = [10, 20, 30, 40] Output = [[10, 20], [30, 40]] The array gets divided into chunks where each sub-array contains the specified number of elements. Using slice() Method with for Loop The slice() method creates a shallow copy of a portion of an array ...
Read MoreHow to dynamically create radio buttons using an array in JavaScript?
Creating radio buttons dynamically using an array in JavaScript is a useful way to provide users with multiple options for input. When the user clicks on one of the radio buttons, it will be selected and any other choices will be deselected automatically. This process can be automated by looping through an array that contains all the possible values and creating a new radio button element for each item in the array. To dynamically create radio buttons using an array, use the concept of createElement() and appendChild(). Let's look at the concept to understand more about dynamically creating ...
Read More