Nikitasha Shrivastava

Nikitasha Shrivastava

163 Articles Published

Articles by Nikitasha Shrivastava

Page 16 of 17

Find the Exact Individual Count of Array of String in Array of Sentences in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 359 Views

In JavaScript, you often need to count how many times specific strings appear in an array of sentences. This article demonstrates how to find the exact individual count of each string from a given array within multiple sentences using regular expressions and word boundaries. Understanding the Problem Given an array of strings and an array of sentences, we need to count how many times each string appears across all sentences. The key requirement is to match complete words only, not partial matches within other words. ...

Read More

Manipulating objects in array of objects in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 4K+ Views

In JavaScript, manipulating objects within an array of objects is a common task. JavaScript provides several built-in array methods like map(), filter(), find(), and slice() to efficiently handle these operations. What is Object Manipulation in Arrays? Object manipulation in arrays involves three main operations: Updating - Modifying existing object properties Filtering - Selecting objects based on criteria Adding - Creating new objects or properties JavaScript provides methods like map(), filter(), find(), slice(), sort(), reduce(), and others to perform these manipulations efficiently. Original Array ...

Read More

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

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 991 Views

In JavaScript, mapping an array to a new array with default values is a common task when you need to transform data while ensuring missing or invalid values are replaced with fallback values. What is Array Mapping? Array mapping creates a new array by transforming each element of an existing array through a callback function. The original array remains unchanged, and the new array has the same length. const numbers = [1, 2, 3]; const doubled = numbers.map(x => x * 2); console.log(numbers); // Original unchanged console.log(doubled); // New transformed array ...

Read More

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

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 974 Views

In JavaScript, checking if array items are consecutive without sorting requires verifying that elements form an unbroken sequence. We can solve this using mathematical properties and built-in array methods. What are Consecutive Items in an Array? Consecutive elements form an unbroken sequence where each number differs by exactly 1 from the next. For example, [1, 2, 3, 4, 5] contains consecutive items in ascending order, while [5, 4, 3, 2, 1] is consecutive in descending order. Example Input/Output Input: [11, 12, 13] Output: true Input: [21, 11, 10] Output: false Method 1: ...

Read More

Get value for key from nested JSON object in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 18K+ Views

In JavaScript, accessing values from nested JSON objects is a common task when working with APIs and complex data structures. We can retrieve nested values using dot notation, bracket notation, or custom functions. Before exploring different approaches, let's understand what JSON and nested JSON objects are: What is JSON and Nested JSON Objects? JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data. It's widely used for data transmission between web applications and servers. Nested JSON objects contain objects within other objects, creating a hierarchical structure. Each nested property has a unique path ...

Read More

Convert number to characters in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 7K+ Views

In JavaScript, converting numbers to characters is commonly done using ASCII/Unicode values. JavaScript provides the built-in String.fromCharCode() method to convert numeric values to their corresponding characters. The String.fromCharCode() Method The String.fromCharCode() method converts Unicode values to characters. Each number represents a specific character in the ASCII/Unicode table. Syntax String.fromCharCode(num1, num2, ..., numN) Example: Single Number to Character const n = 65; const c = String.fromCharCode(n); console.log(c); console.log("Number 72 becomes:", String.fromCharCode(72)); console.log("Number 101 becomes:", String.fromCharCode(101)); A Number 72 becomes: H Number 101 becomes: e In this ...

Read More

Grouping data to month wise in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 977 Views

In JavaScript, grouping and sorting data by months is a common requirement when working with date-based information. This involves sorting objects first by year, then by month in chronological order from January to December. Arrays in JavaScript provide powerful methods like sort() and indexOf() that make this task straightforward. The key challenge is properly comparing month names since they need to be sorted in calendar order, not alphabetically. Problem Statement Given an array of objects with year and month properties, we need to sort them chronologically. For example: const data = [ ...

Read More

Finding Lucky Numbers in a Matrix in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 964 Views

In the given problem statement we have to write a function to get the lucky numbers in a matrix with the help of Javascript. A lucky number is defined as an element that is the minimum value in its row and the maximum value in its column. Understanding the Problem Statement A lucky number in a matrix must satisfy two conditions: It is the minimum element in its row It is the maximum element in its column For example, in the matrix [[3, 7], [9, 11]], the number 7 ...

Read More

Find number of spaces in a string using JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 3K+ Views

In JavaScript, counting spaces in a string is a common task that can be accomplished using several built-in methods. This article explores different approaches to find the number of space characters in a string. Problem Overview Given a string with space characters, we need to count how many spaces it contains. For example, the string "Hello world example" contains 2 spaces. const exampleString = "This is an example of counting spaces"; // Expected output: 6 spaces Method 1: Using split() Method The split() method divides a string into an array based on a ...

Read More

Calculating median of an array in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 4K+ Views

In this problem statement, our task is to calculate the median of an array with the help of Javascript functionalities. There are several ways that can be used to solve this task. One simple method to calculate median is using the built-in function of Javascript. Understanding the Problem The problem statement is to write a function in Javascript that will help to calculate the median of a given array. The median is the middle value when numbers are arranged in ascending order. For example: Array [1, 2, 3, 4, 5] has median 3 (middle element) Array ...

Read More
Showing 151–160 of 163 articles
Advertisements