Found 6710 Articles for Javascript

JavaScript Program For Reversing A Linked List In Groups Of Given Size

Prabhdeep Singh
Updated on 12-Apr-2023 12:22:20

224 Views

A linked list is a linear data structure that consists of interconnected nodes. Reversing a linked list means changing the order of all its elements. Reversing a linked list in groups of a given size means, we are given a number and we will reverse the first given number of elements, and then for the next set we will reverse the elements. We will see the proper code with implementation. Examples Given linked list: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> null Given number: 3 Output: 3 -> 2 -> ... Read More

JavaScript Program for Reversal algorithm for right rotation of an array

Prabhdeep Singh
Updated on 12-Apr-2023 12:21:05

233 Views

Right rotation of an array means to rotate the elements of the array to their right side by a given number of times and for the number which are present at the edge they will move to the first index in their right rotation by assuming an array in a cycle form. We will implement a proper code to implement the algorithm with an explanation. Example Let us assume we have given array as [1, 2, 3, 4, 5, 6, 7, 8, 9] The number of right rotations of the array is 3 Output: 7 8 9 1 2 ... Read More

JavaScript Program for Reversal algorithm for array rotation

Prabhdeep Singh
Updated on 12-Apr-2023 12:19:55

254 Views

An array is a linear data structure used to store the different types of objects and we are given an array of size n and an integer k (where k is the number by which we will rotate an array). We will rotate the array by k elements and then return the rotated array. Rotation means we have to traverse the array from the given kth element and shift all the integers by one and we have to shift each element by 1 till the kth element came to position ‘0’ or we can say at index number ‘0’. Note ... Read More

JavaScript Program for Removing Duplicates From An Unsorted Linked List

Prabhdeep Singh
Updated on 12-Apr-2023 12:18:55

252 Views

The linked list is a linear data structure that consists of nodes, and each node is stored in memory in a non-contiguous manner. Nodes are connected by storing the address of the next node. We are given a linked list that will contain some integers in a random manner and not in a sorted manner. The task is to find the elements of the linked list which are repeated and we have to remove the duplicated ones. We will see the proper code and explanation. In this problem, we will keep the first copy of the elements of the ... Read More

Javascript Program For Removing Duplicates From A Sorted Linked List

Prabhdeep Singh
Updated on 12-Apr-2023 12:17:02

363 Views

Linked list is linear data structure and we have given a sorted linked list that consists of the integers. There are some numbers that may be duplicated or repeated and we have to remove them. As the given linked list is sorted, we can simply iterate over it and by using the while loop can remove the duplicate nodes from it. We will implement a proper code to understand the logic better with the discussion of time and space complexity. Example Given linked list is: 1-> 2 -> 2 -> 3 -> 4 -> 4 -> 4 -> 5 -> ... Read More

Javascript Program for Range Queries for Frequencies of array elements

Prabhdeep Singh
Updated on 12-Apr-2023 12:15:19

190 Views

We are given an array that will contain integers and another array will be given that will contain the queries and each query represents the range that we are given by the leftmost and the rightmost index in the array and an element. For that range or the subarray, we have to find the frequency of the given element present in that range. The frequency of the elements means that we have to tell for each integer present in that range how many times it occurs. For example − If, the given array is: [5, 2, 5, 3, 1, 5, ... Read More

How to create form dynamically with the JavaScript

Aman Gupta
Updated on 11-Apr-2023 13:59:00

6K+ Views

Overview To create a HTML form fully dynamic can be created using some of the Document Object Model (DOM) methods such as createElement(), setAttribute(), appendChild(). These DOM methods will help us to build a dynamic HTML form. Our approach to building this dynamic form will be by creating all the elements in the script tag , setting the attribute to add some functionality and at last when our element is ready to serve we will append it in the parent of the element. So all the elements appended inside the parent form tag are the children elements. Syntax The ... Read More

How to create a FAQ page using JavaScript

Aman Gupta
Updated on 11-Apr-2023 13:54:40

1K+ Views

Overview The Frequent Asked Question (FAQ) is the main feature for the website which deals with the selling of products, registration for training or companies in a particular domain. There are many problems which arise for many users or can arise, so these questions and the solution for these problems are displayed in the FAQ section, so that if any user is facing any error he can resolve it by going through the FAQ part of the website and can continue his work. Approach The main approach to make a FAQ is an accordion. All the frequently asked questions ... Read More

How to Create a Dropdown List with Array Values using JavaScript

Aman Gupta
Updated on 11-Apr-2023 13:49:54

9K+ Views

Overview To attain the options in the Dropdown list without disturbing the frontend of the web page can be with the help of array. As in the array we can store as many numbers of the option or values. So without directly putting those values in the HTML part of the code in the select tag we can render them from an array which makes it easy to add more value without disturbing the User Interface (UI) of the page. Approach This is a very simple technique, by using this technique we can easily render the options value to ... Read More

How to add bootstrap toggle-switch using JavaScript?

Aayush Mohan Sinha
Updated on 10-Apr-2023 14:45:38

1K+ Views

The Bootstrap library provides a number of features to the user to make their coding experience smooth. One of such features which the user can choose from is the toggle-switch. The toggle-switch, one of its useful features, provides users the ability to add components which can switch between two states such as on and off. Bootstrap Toggle-switch The Cascading Style Sheets (CSS) framework Bootstrap is a toolkit that makes it simpler and more standards-compliant to create websites. It can be used, alongside JavaScript, to create a responsive user interface. The simple Bootstrap toggle-switch component is used to select one of ... Read More

Advertisements