Found 9320 Articles for Object Oriented Programming

Check if items in an array are consecutive but WITHOUT SORTING in JavaScript

Nikitasha Shrivastava
Updated on 22-Aug-2023 14:21:54

578 Views

In the above statement we are asked to check if items in an array are consecutive without sorting the array with the help of javascript functionalities. We can solve this problem with some basic functionalities of javascript. Let us see how to do this! What are Consecutive Items in an Array ? Consecutive elements means every next item should be greater or smaller to the previous element in the sequence. For example we have an array [1, 2, 3, 4, 5], So here we can see that the array contains all the consecutive items as they are in increasing ... Read More

Mapping an array to a new array with default values in JavaScript

Nikitasha Shrivastava
Updated on 23-Aug-2023 17:46:32

674 Views

In the given problem statement we are required to map an array to a new array with default values with the help of javascript functionalities. In Javascript we have some built−in function to map an array to a new array as per the condition and requirement. What is an array in Javascript ? An array is a collection of similar data elements under one roof. So let's understand the overall working process of arrays in JavaScript. An array is an object that contains one or more elements. Example const arr = ['A', 'B', 'C', 'D']; console.log(arr); Output [ ... Read More

Convert object to array of objects in JavaScript

Nikitasha Shrivastava
Updated on 22-Aug-2023 15:49:17

436 Views

In the given problem statement we are required to convert an object to an array of objects with the help of javascript functionalities. To perform conversion of an object into an array of objects we can use Javascript’s built−in methods. What is an Array in Javascript ? An array is a collection of similar data elements under one roof. So let's understand the overall working process of arrays in JavaScript. An array is an object that contains one or more elements. So it has some properties and methods that make working with arrays easier in JavaScript. For example const ... Read More

Manipulating objects in array of objects in JavaScript

Nikitasha Shrivastava
Updated on 23-Aug-2023 17:41:43

2K+ Views

In the given problem statement we are asked to manipulate objects in an array of objects with the help of javascript functionalities. In Javascript we have some built−in functions called map(), reduce(), forEach() and filter() to manipulate the objects in an array. We can solve this problem with the help of these functions. What is the manipulating object in an array ? Let's understand the manipulation of objects in an array. Manipulation means updating an array object, deleting an array object or adding an object in an array. In Javascript, there are several methods present to do these kinds of ... Read More

Truncating a String in JavaScript

Nikitasha Shrivastava
Updated on 23-Aug-2023 13:21:32

3K+ Views

In the given problem statement we are asked to truncate a string with the help of javascript functionalities. We can solve this problem with the help of Javascript’s built−in functions slice() and substr(). What do you mean by truncating a string ? Let's understand the meaning of truncating a string. Truncating a string means cutting the length of a string by removing character from the beginning, end or middle part of the input string. The aim of truncating a string is to make a certain space or to make it more readable by truncating unnecessary information from the input ... Read More

Function to decode a string in JavaScript

Nikitasha Shrivastava
Updated on 23-Aug-2023 12:40:51

844 Views

In the given problem statement we are asked to implement a function to decode a string with the help of javascript functionalities. To solve these kinds of problems we can use built−in functions of Javascript. These functions usually take encoded data as input and give output as decoded strings. What are built−in methods to decode strings in Javascript? Let's understand techniques to decode strings in javascript. In javascript, if we need to decode a string we can use different built−in methods. Some methods are: decodeURIComponent(), unescape() and atob(). We will see the working of all the methods in detail below. ... Read More

How to implement backtracking for a climbing stairs practice in JavaScript?

Nikitasha Shrivastava
Updated on 23-Aug-2023 13:01:08

230 Views

In the given problem statement we are asked to implement backtracking for a climbing stairs practice with the help of javascript functionalities. In the data structures backtracking is popularly known to explore all the possible solutions. We can solve this problem with the help of a backtracking algorithm. What is the Backtracking Technique ? Let's understand the working of a Backtracking technique. Backtracking is a well known algorithm technique, which is basically used to solve the problem statements that include searching for all possible solutions. It is based on a depth−first strategy and it is used in combination with a ... Read More

Finding all possible combinations from an array in JavaScript

Nikitasha Shrivastava
Updated on 23-Aug-2023 12:34:26

951 Views

In the given problem statement we are asked to find all the possible combinations from an array with the help of javascript functionalities. So for this we will be working with an empty array and add all the possible combinations into this array. Logic for The Above Problem The easiest way to find the possible combinations from an array in javascript is by using a for loop add the combination to the created new array.. To understand the logic for this implementation we will work by iterating through the input array and for each element we will create a ... Read More

Fibonacci like sequence in JavaScript

Nikitasha Shrivastava
Updated on 23-Aug-2023 12:37:52

268 Views

In the given problem statement we are asked to create a fibonacci like sequence with the help of javascript functionalities. In the Javascript we can solve this problem with the help of recursion or using a for loop. What is the Fibonacci Sequence ? Let's understand the working of a Fibonacci sequence in JavaScript. As we know that Fibonacci sequence is a sequence of numbers in which every number is the sum of the two forgoing numbers. The series starts from 0 and 1. The next number in the series is 1 (0 + 1), followed by 2 (1 ... Read More

Calculate the difference between the first and second element of each subarray separately and return the sum of their differences in JavaScript

Nikitasha Shrivastava
Updated on 22-Aug-2023 14:13:17

255 Views

In the given problem statement we are asked to calculate the difference between the first and second element of each subarray separately and we have to return the sum of their differences with the help of javascript functionalities. In the array data structures we can define an array which can also contain subarrays. What is an Array of Subarrays in JavaScript ? Let's understand the working of a list in JavaScript. In javascript we can define array of subarray or nested array. An array of subarrays is an array which contains one or more arrays as its elements. Every array ... Read More

Advertisements