Found 6710 Articles for Javascript

How to convert Hex to RGBA value using JavaScript?

Saurabh Jaiswal
Updated on 21-Apr-2023 16:56:09

3K+ Views

While designing web pages we use colors to make web pages more appealing and engaging. We commonly use hex code to represent colors but sometimes we need to add transparency to the colors which can be achieved by RGBA values. Hex color values are represented by #RRGGBBAA and The RGBA color values are represented by rgba( red, green, blue, alpha). Here are a few examples of RGBA and hex values − Input: #7F11E0 Output: rgba( 127, 17, 224, 1 ) Input: #1C14B0 Output: rgba( 28, 20, 176, 1 ) In ... Read More

How to Use Conditional Statements On Objects?

Yaswanth Varma
Updated on 21-Apr-2023 15:51:23

844 Views

Conditional statements are used to control how an execution will proceed in response to various circumstances. You can take one action if a condition is true and another action if the condition is false. Conditional statements are the component of a computer program's logic, decision-making, or flow control. The task we are going to perform in this article was using conditional statements on objects. Let’s dive into the article for getting better understanding on conditional statements. Using if statement The if statement is the most basic type of conditional expression. If a statement is evaluated to see whether it is ... Read More

How To Show Only One V-Menu At A Time When Clicking To Show The Menu?

Yaswanth Varma
Updated on 21-Apr-2023 15:50:05

949 Views

The task we are going to perform in this article was how to show only one v-menu at a time when clicking to show the menu, let’s dive into the article for getting better understanding on v-menu. A customized version of NativeUI was used to create the server-side trainer and menu known as vMenu. It features complete permissions support, allowing the server owner to control who can do what. Displaying v-menu A user interface's menu is a flexible element. It displays a popover with a variety of uses, like presenting a menu of choices. They may be used in conjunction ... Read More

How To Modify This JavaScript Code To Grab An Image URL From A JSON File, And Display It In HTML?

Yaswanth Varma
Updated on 20-Apr-2023 17:16:40

10K+ Views

This can be done by using the JavaScript method JSON.parse() to parse through the JSON file and extract the URL of the desired image. Then, an HTML img tag can be created with a source attribute set to this URL. Finally, this img tag can be appended to an existing HTML element in order to display it on your page. This will require some knowledge of basic JavaScript syntax, as well as familiarity with how JSON is structured and parsed within it. With these skills in hand, you should have no trouble modifying your code to achieve your goal! Let’s ... Read More

JavaScript Program for Check if an array is sorted and rotated

Prabhdeep Singh
Updated on 21-Apr-2023 09:16:19

290 Views

A sorted array is an array where all the elements are present in increasing order. We have given an array of size N and an array containing the distinct integers (which means every integer is present only one time). We have to check the array is sorted and rotated in a clockwise direction. Here we have to return ‘YES’ if the array is sorted and rotated otherwise, we have to return ‘NO’. Note − Here we are talking about the sorted and rotated means at least one rotation should be present. We cannot consider a sorted array as a sorted ... Read More

JavaScript Program for Ceiling in a sorted array

Prabhdeep Singh
Updated on 21-Apr-2023 09:10:43

211 Views

An array is a linear data structure that contains the objects and in sorted array elements are present in increasing order. We have given a sorted array and an integer x. We have to print the ceiling of the integer x from the given array. The ceiling of a sorted array with value x is the smallest element larger than or equal to x, while the floor is the largest member less than or equal to x. If the ceiling of the x does not exist in the array we have to print ‘ceiling of x does not exist in ... Read More

JavaScript Program for Block Swap Algorithm for Array Rotation

Ravi Ranjan
Updated on 06-Jun-2025 19:37:06

316 Views

To implement block swap algorithm for array rotation, we will be understanding three different approaches. Rotation of the array elements means moving the elements of the given array to either the left or right side by some number of specific positions. Block swap algorithm for array rotation means to rotate the elements of the array by a given number but not using the rotation but the swapping technique. In this article we are having an array and a variable d by which array will be rotated, our task is to write a JavaScript program for block swap algorithm for array ... Read More

JavaScript Program to Check If a Singly Linked List is Palindrome

Prabhdeep Singh
Updated on 20-Apr-2023 17:19:55

303 Views

A singly linked list is a linear data structure that is stored in a non-contiguous way in the memory and each block is connected by holding the address of the next block also known as a node. A palindrome can be explained as a set of characters, digits, etc, and it reads the same from both the front and backside. We will be given a singly linked list and have to find whether the values stored at the nodes are equal from both the front and backside. Input 1 -> 2 -> 3 -> 3 -> 2 -> 1 ... Read More

JavaScript Program to Check if a Matrix is Symmetric

Prabhdeep Singh
Updated on 12-Dec-2024 12:22:52

626 Views

To check if a matrix is symmetric, we simply check if the matrix and it's corresponding transpose matrix are equal. A symmetric matrix is a special case of a matrix where both the matrix and the transpose of the matrix are the same (A = A^T). In this article we are given with an array and our task is to write a JavaScript program to check if a matrix is symmetric. Users must be familiar with 2D matrix, transpose of matrix, symmetric matrix, nested loop and if/else statement. Example Input: matrix [A]: [[1, 2, ... Read More

JavaScript Program to Check if a Given Matrix is Sparse or Not

Prabhdeep Singh
Updated on 15-Dec-2024 16:29:10

252 Views

To check if a given matrix is sparse or not, we will be discussing two different approaches, their complexities, and example codes. A sparse matrix is a special type of matrix in which the number of zeroes is strictly more than half of the the total number of elements present in the given matrix. In this article we are having a 2D matrix, our task is to write a JavaScript program to check if a given matrix is sparse or not. Users must be familiar with conditional statement, nested for loop and javascript methods. Example Input: Matrix: [[1, ... Read More

Advertisements