
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6710 Articles for Javascript

138 Views
We will be implementing a JavaScript program to find an element at a given index after a number of rotations. This program will require us to perform rotations on an array and then return the element present at the specified index. To accomplish this task, we will be using the modulo operator to calculate the new index after each rotation. The future continuous tense will be used throughout the explanation. In the program, we will be taking the input of the array, the number of rotations, and the index. We will then perform the rotations by using the modulo operator ... Read More

498 Views
To find difference between sums of two diagonals, we will be discussing two different approaches. We will calculate the sum of the elements present in the left and right diagonal, then we will subtract both sum values to get the difference. In this article we are having a square matrix, our task is to write a JavaScript program to find difference between sums of two diagonals. Example Input: Matrix: [[1, 2, 3], [4, 5, 6], [9, 8, 9]] Sum of left diagonal elements = 1+5+9 = 15 Sum of right diagonal elements = 3+5+9 ... Read More

3K+ Views
To find closest number in array using Javascript, we will be understanding and discussing three different approaches. We will also compare time and space complkexities of all the appproaches used. In this article we are having an array and a target value, our task is to find closest number to target value in array using Javascript. User must know about JavaScript arrays, searching alogorithms such as linear and binary search, sorting, loops, and conditional statement. Approaches to Find Closest Number in Array Here is a list of approaches to find closest number in array in JavaScript which we will ... Read More

196 Views
We will write a JavaScript program to find the sum of an array by using bitwise OR after splitting the given array into two halves after K circular shifts. Our program will perform the task by taking an array and an integer K as inputs. First, we will split the array into two halves after performing K circular shifts. Then, we will perform bitwise OR on both the halves to get a new array. Finally, we will find the sum of the new array obtained from the bitwise OR operation. Approach First, perform K circular shifts on the given ... Read More

16K+ Views
In JavaScript, “” represents the empty string, and we can use the null keyword to initialize the string with a null value. If we don’t assign any value to any variable, it is undefined by default. Sometimes, we need to check if the string is empty, undefined, or null while working with the strings. For example, we are taking the details from the users via an HTML form, and users can add an empty string to the input field; we need to validate the input field and show the error message to the users. In this tutorial, we will learn ... Read More

19K+ Views
To find area of a circle using javascript, we will be using simple formulae of calculating the area of circle. The formula used is: Area = π × r² where r is the radius and π is a constant value pi. In this article, we are having radius of the circle and our task is to find the area of the circle using JavaScript. Example let radius = 10 and π(pi) = 3.1415926535 Area = π × r² Area= 3.1415926535 * 10 * 10 Area= 314.15926535 Steps to Find Area of Circle ... Read More

9K+ Views
To find the area and perimeter of a rectangle in JavaScript, we will be using the basic formulas for the perimeter and area of a rectangle. The area of a rectangle is the multiplication of its length by its breadth, and the perimeter of a rectangle is the sum of the lengths of all its four sides. In this article, we are going to understand the formula for the area and perimeter of a rectangle, how to find them using JavaScript, and implement practical examples for this. Understanding the Formulas The formulas for the area and perimeter of a ... Read More

525 Views
In this article, we will learn to find three numbers in an array that add up to a given sum value using JavaScript. We are going to write a JavaScript program to find a triplet that sums up a given value. This program will make use of nested loops to iterate over the input array and check for the existence of a triplet with a sum equal to the given value. We'll present two different approaches and analyze their implementations. Sorting and Two-Pointer Technique The first approach uses sorting and the two-pointer technique to solve the problem efficiently. This method ... Read More

316 Views
We will be writing a JavaScript program that finds a triplet where the sum of two elements equals the third element. This program will be implemented using arrays and loop structures. We will be iterating through the array and checking for each element if the sum of two elements equal to the current element. If we find such a triplet, we will immediately return it. This program will be helpful in various mathematical computations where we need to find such triplets that follow a specific rule. Approach Here is one approach to solving the problem of finding a triplet such ... Read More

414 Views
To efficiently compute sums of diagonals of a matrix, we will be discussing two different approaches. We will calculate the sum of the elements present in the left-to-right and right-to-left diagonal i.e primary and secondary diagonal respectively. In this article we are having a square matrix, our task is to write a JavaScript program to efficiently compute sums of diagonals of a matrix. Example Input: Matrix: [[1, 2, 3], [4, 5, 6], [9, 8, 9]] Sum of primary diagonal elements = 1+5+9 Sum of secondary diagonal elements = 3+5+9 Output: Sum of ... Read More