How to handle navigation from one page to another in react native?

Shilpa S
Updated on 15-Mar-2026 23:19:00

4K+ Views

While working on the app, we would like to switch from one screen to another and that is handled by React Navigation library. Installation To work on navigating pages we need to install few packages as follows: npm install @react-navigation/native @react-navigation/stack npm install @react-native-community/masked-view react-native-screens react-native-safe-area-context react-native-gesture-handler Once you are done with the above installation let us now proceed with the next setup of navigation in React Native. Creating Page Components In your app project create a folder called pages/. Create 2 js files HomePage.js and AboutPage.js. pages/HomePage.js import ... Read More

How to Declare an Object with Computed Property Name in JavaScript?

Mayank Agarwal
Updated on 15-Mar-2026 23:19:00

526 Views

In JavaScript, computed property names allow you to dynamically create object properties using expressions inside square brackets. This ES6 feature provides flexibility when property names need to be determined at runtime. JavaScript Object – A JavaScript object contains key-value pairs where the key represents a property from which we can get and set the value of an object. Using Square Bracket Notation in Object Literals We can use square bracket expressions [] to create computed property names directly in object literals. In ES6, it's possible to use any expression within the brackets. Example 1 In ... Read More

Consecutive elements sum array in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

583 Views

We are required to write a JavaScript function that takes in an array of Numbers and returns a new array with elements as the sum of two consecutive elements from the original array. For example, if the input array is − const arr1 = [1, 1, 2, 7, 4, 5, 6, 7, 8, 9]; Then the output should be − const output = [2, 9, 9, 13, 17] How It Works The function pairs consecutive elements: (1+1=2), (2+7=9), (4+5=9), (6+7=13), (8+9=17). If the array has an odd length, the last ... Read More

Accessing and returning nested array value - JavaScript?

Yaswanth Varma
Updated on 15-Mar-2026 23:19:00

2K+ Views

Each value in an array is referred to as an element, and each element has a certain numerical location in the array, which is referred to as its index. Nested Arrays, a feature of JavaScript, allow us to create arrays inside arrays. One or more arrays can be used as the elements of nested arrays. Although the term may be a little unclear, as we look further, it is actually rather fascinating. Understanding Nested Arrays In JavaScript, a nested array is described as an Array (outer array) inside another array (inner array). One or more inner arrays ... Read More

Iterate through Object keys and manipulate the key values in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

324 Views

When working with arrays of objects in JavaScript, you often need to iterate through object keys and transform their values. This article demonstrates how to extract specific elements from array values within objects. Problem Statement Suppose we have an array of objects where each property contains an array of values: const arr = [ { col1: ["a", "b"], col2: ["c", "d"] }, { ... Read More

Convert the number or boolean type JSON object from string type to its original in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

1K+ Views

Suppose we have a JSON object where numeric and boolean values are stored as strings: const obj = {"name":"sam", "age":"24", "isMarried":"false"}; console.log(obj); { name: 'sam', age: '24', isMarried: 'false' } Here, the age property should be a number and isMarried should be a boolean. Our goal is to write a function that converts these string values back to their correct data types. Method 1: Using parseInt and Boolean Conversion This approach checks each property and converts numeric strings to numbers and boolean strings to booleans: const obj = { ... Read More

Combination sum problem using JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

630 Views

The combination sum problem involves finding all unique combinations from a given array where the numbers sum to a target value. Each number can be used multiple times, making this a classic backtracking problem. Problem Statement Given a set of candidate numbers (without duplicates) and a target number, find all unique combinations where the candidate numbers sum to the target. Constraints: All numbers (including target) are positive integers The same number may be chosen multiple times The solution set must not contain duplicate combinations Example: Input: candidates = ... Read More

Check if a string is repeating in itself in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

905 Views

In JavaScript, we often need to determine if a string consists of a repeating pattern. This involves checking if the entire string can be formed by repeating a smaller substring multiple times. For example, the string 'carcarcarcar' is made by repeating 'car' four times, so it should return true. However, 'abcdef' has no repeating pattern, so it should return false. Problem Understanding We need to write a function that: Takes a string as input Returns true if the string is formed by repeating a pattern Returns false if no repeating pattern exists Example Input ... Read More

Checking if a string can be made palindrome in JavaScript

Aayush Mohan Sinha
Updated on 15-Mar-2026 23:19:00

935 Views

In JavaScript, determining if a string can be made into a palindrome by removing at most one character is a common algorithmic problem. A palindrome reads the same forwards and backwards, like "racecar" or "level". Problem Statement Given a string, we need to check if it can become a palindrome by removing at most one character. The function should return true if possible, false otherwise. Sample Input: "racecar" Sample Output: true Using Two Pointers (Recommended) The most efficient approach uses two pointers starting from both ends of the string, moving towards the center while comparing ... Read More

Preparing numbers from jumbled number names in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

216 Views

Problem Suppose we have the following jumbled number name string: const str = 'TOWNE'; If we rearrange this string, we can find two number names in it: 2 (TWO) and 1 (ONE). Therefore, we expect an output of 21. We need to write a JavaScript function that takes in one such string and returns the numbers present in the string arranged in ascending order. Approach The solution involves: Creating a mapping of number words to their numeric values Generating permutations to check if number words can ... Read More

Advertisements