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
Articles by Nikitasha Shrivastava
Page 15 of 17
Mapping values to keys JavaScript
In the given problem statement we have to write a method for mapping values to keys with the help of Javascript. So for doing this task we will use an object literal in Javascript. Understanding the problem statement So we have to find out the value for the given key and for doing this task we can use an object literal. An object is a data structure which can store the data in key-value pairs. So the keys are the identifier of the values. With the help of keys we can access the values. In Javascript there are several methods ...
Read MoreFinding Lucky Numbers in a Matrix in JavaScript
In the given problem statement we have to write a function to get the lucky numbers in a matrix with the help of Javascript. So we will implement this task with for loops and functions of Javascript. Understanding the problem statement The problem statement is asking us to find the lucky numbers in a given matrix. So the lucky number will be defined as a number in the matrix which is the minimum value for its own row and the maximum value for its column. For example we have a matrix [ [3, 7], [9, 11] ], in this ...
Read MoreJavaScript Count repeating letter
In this problem statement, our target is to count the repeating letter in the given string with the help of Javascript functionalities. So we can solve this problem with the help of loops and some built-in methods of Javascript. Logic for the given problem In the given problem statement we have to design a program to count the repeating letters in the given string. For implementing this task first we will create a blank object for count, array for repeated characters and another object for results. Then we will loop through every character in the string. So for every ...
Read MoreJavaScript - How to create nested unordered list based on nesting of array?
In this problem statement, our task is to to create a nested unordered list based on nesting of arrays with the help of Javascript. So for doing this task we will use a function to call recursively for each nested array and create a new unordered list.. Understanding the problem statement In the above problem statement we have to create a function for a nested list in HTML using Javascript. The input for the code will be an array that can have any number of items and can also include other arrays that represent nested lists. The code will be ...
Read MoreImplementing counting sort in JavaScript
In the given task, our aim is to create a counting sorting technique and implement this problem with the help of Javascript functionalities. What is the Counting Sort? The counting sort is a process for sorting a data set of objects as per the keys. It works by counting the number of items that have different key values and finding the position of each object in the sorted output. The idea of counting sort is to place the items directly into its correct place in the output array. In the beginning of the algorithm we need to find ...
Read MoreHow to write the factorial function with reduce and range in JavaScript?
In this problem statement, our aim is to write the factorial function with reduce and range with the help of Javascript. So basically range and reduce are the predefined functions of Javascript. What is the use of reduce and range functions in Javascript ? In Javascript the reduce and range functions are the most useful function when working with arrays. The reduce function takes an array and reduces it to a single value by processing a function for every item of the array. The function takes two parameters, the first one is the accumulator which stores the result of ...
Read MoreHow to find distance between items on array JavaScript?
In this problem statement, our aim is to find the distance between items on an array with the help of Javascript. So for doing this task we will use a loop and a variable to store the id for each object in the JSON object. Understanding the problem statement The problem statement is to write a function in Javascript by which we can find the distance between items on an array. If we have an array, the distance will be measured by counting the index numbers from the first item from where we have to measure the distance. For example ...
Read MoreGiven an array of integers, find the pair of adjacent elements that has the largest product and return that product JavaScript
Our work in this problem statement is to find the pair of adjacent elements that has the largest product and return the product if we have given an array. And we have to implement this problem with the help of Javascript functionalities. Logic for the given problem In the given problem statement we have to calculate the product of the largest elements in the array and show the resultant output to the console. So we will implement this problem with two methods: first is by using the infinity and second without using infinity. Infinity is a global object. The ...
Read MoreGet key from value in JavaScript
In the given problem statement we have to write a function which will help to get the key of the given value with the usage of Javascript functionalities. So basically in Javascript if we want to access the keys or value from the given object we can access it by dot notation or bracket notation. Understanding the problem statement The problem statement says that we have to find a key from a value in a Javascript object. That means we are given a Javascript object and a value so we need to find the corresponding key which maps to that ...
Read MoreGet all substrings of a string in JavaScript recursively
In the provided problem statement, our aim is to get all substrings of a string recursively with the help of Javascript. So here we will be creating a recursive function that can generate all possible substrings of a given input string. Understanding the problem statement The problem statement is asking us to create a recursive function which can generate all the possible substrings of a given input string with the help of Javascript. A substring is any continuous sequence of characters within the input string. For example: input strings “xy" so the possible substrings are "x", "y", and "xy". Algorithm ...
Read More