- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 10677 Articles for Web Development
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
662 Views
We are required to write a JavaScript function that takes in a string as the first and the only argument.The function should detect if the string is a repetition of a same set of characters or not.If it is a repetition of the same set of characters then we should return true, false otherwise.For example −If the input string is −const str = 'carcarcarcar';Then the output should be −const output = true;because the string 'car' is getting repeated over and over again in the string.ExampleFollowing is the code −const str = 'carcarcarcar'; const isRepeating = (str = '') => { ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
261 Views
We are required to write a JavaScript function that takes in a string of characters as the first argument, say str, and a number, say num, as the second argument.The function should count the number of palindrome strings all exactly of length num can be constructed from the given string str. The function should then finally return the count.For example −If the input string and the number is −const str = 'ij'; const num = 4;Then the output should be −const output = 4;because those four possible palindrome strings are −'iiii', 'jjjj', 'ijji', 'jiij'Approach:We will first count the number of ... Read More
475 Views
Effectively manipulating data structures is a crucial aspect of contemporary software development. In JavaScript, one typical task is relocating all the zeros in an array to the end, while preserving the order of the non-zero elements. Although various methods exist to achieve this, the in-situ algorithm is a particularly potent technique that avoids the necessity of extra data structures. In this discourse, we will scrutinize the complexities of the in-situ algorithm to move zeros to the end of an array in JavaScript, probing the underlying reasoning and offering systematic instructions for execution. By mastering this technique, software developers can refine ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
879 Views
We are required to write a JavaScript function that takes in a string of characters as the only argument.The function should build and return the acronym based on the string phrase provided as input.While constructing the acronym the function should take only those words into consideration that starts with an uppercase letter.For example −If the input string is −const str = 'Polar Satellite Launch Vehicle';Then the output should be −const output = 'PSLV';ExampleFollowing is the code −const str = 'Polar Satellite Launch Vehicle'; const buildAcronym = (str = '') => { const strArr = str.split(' '); let res ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
369 Views
We are required to write a JavaScript function that takes in a two-dimensional array of integers as the only argument.The task of our function is to calculate the count of all such integers from the array that are the greatest both within their row and the column.The function should then return that count.For example −If the input array is −const arr = [ [21, 23, 22], [26, 26, 25], [21, 25, 27] ];Then the output should be −const output = 3;because those three numbers are 26, 26, 27ExampleFollowing is the code −const arr = [ [21, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
110 Views
We are required to write a JavaScript function that takes in a string of characters as the first argument and a start index and end index as second and third argument respectively. The function should find, had that string, provided as the first argument, been extended forever by appending the same string at end each time, what would have been the substring encapsulated by the start index and the end index.For example −If the input string and the indices are −const str = 'helloo'; const start = 11; const end = 15;Then the output should be −const output = 'hel';ExampleFollowing ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
68 Views
We are required to write a JavaScript function that takes in two strings of characters lets call them str1 and str2.The function should check whether we can form str2 from str1 by deleting exactly one character from str1. If we can do so the function should return true, false otherwise.For example −If the input strings are −const str1 = 'chemistty'; const str2 = 'chemisty';Then the output should be −const output = true;ExampleFollowing is the code −const str1 = 'chemistty'; const str2 = 'chemisty'; const stringSimilarity = (str1 = '', str2 = '') => { if(str1.length - str2.length !== 1){ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
450 Views
We are required to write a JavaScript function that takes in an array of integers as the only argument.The function should sort the integers present in the array in increasing order based on the 1s present in their binary representation. If two or more numbers have the same number of 1s in their binary, they should be sorted in increasing order according to their magnitude.For example −If the input array is −const arr = [34, 37, 23, 89, 12, 31, 23, 89];Then the output array will be −const output = [34, 12, 37, 23, 89, 23, 89, 31];ExampleFollowing is the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
434 Views
We are required to write a JavaScript function that takes in an array of literals as the first and the only argument.Our function should swap each consecutive even index with each other, and swap each consecutive odd indexes with each other.The function should do these swappings in place.For example −If the input array is −const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8];Then the array should become −const output = [2, 3, 0, 1, 6, 7, 4, 5, 8];because 0 and 2 gets swapped, 1 and 3 gets swapped, 4 and 6 gets swapped, 5 and 7 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
50 Views
We are required to write a JavaScript function that takes in an array of integers as the only argument.The function should check whether there exists an integer in the array such that its frequency is same as its value.If there exists at least one such integer, we should return that integer otherwise we should return -1.For example −If the input array is −const arr = [3, 4, 3, 8, 4, 9, 7, 4, 2, 4];Then the output should be −const output = 4;ExampleFollowing is the code −const arr = [3, 4, 3, 8, 4, 9, 7, 4, 2, 4]; const ... Read More