
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 8591 Articles for Front End Technology

151 Views
Arithmetic ProgressionArithmetic Progression (AP) is a sequence of numbers such that the difference of any two consecutive numbers is a constant value (aka common difference).For instance, 1, 2, 3, 4, 5, 6, … is an AP, which has a common difference equal to 1 (2 -1).ProblemWe are required to write a JavaScript function that takes in an array of integers, arr, as the first and the only argument.The task of our function is to return the number of arithmetic progressions of size 3 that are possible from that list. In each progression, the differences between the elements must be the ... Read More

172 Views
ProblemWe are required to write a JavaScript function that takes in a number, num, as the first and the only argument.Our function should compute and return the number of digits in the factorial of the number num.For example, if the input to the function is −Inputconst num = 7;Outputconst output = 4;Output ExplanationBecause the value of 7! Is 5040 which contains 4 digits.ExampleFollowing is the code − Live Democonst num = 7; const countDigits = (num = 1) => { let res = 0; while(num >= 2){ res += Math.log10(num); num--; }; return ~~res + 1; } console.log(countDigits(num));Output4

571 Views
ProblemWe are required to write a JavaScript function that takes in an array of integers, arr, as the first and the only argument.Our function is required to pick and return one such index from the array such that the sum of elements on its left side is equal to the sum of elements on its right side. If there exists no such index in the array, we should return -1.For example, if the input to the function is −Inputconst arr = [1, 2, 3, 4, 3, 2, 1];Outputconst output = 3;Output ExplanationBecause the sum of elements at either side of ... Read More

214 Views
ProblemWe are required to write a JavaScript function that takes in a string, str, as the first and the only argument.Our function should create a new string based on the input string where each character in the new string is '(' if that character appears only once in the original string, or ')' if that character appears more than once in the original string.And we should ignore capitaliFor example, if the input to the function is −Inputconst str = 'Success';Outputconst output = ')())())';ExampleFollowing is the code − Live Democonst str = 'Success'; const mapString = (str = '') => { ... Read More

238 Views
ProblemWe are required to write a JavaScript function that takes in an array of integers, arr, that may contain duplicates as the first argument, and a number, num, as the second and final argument.The task of our function is to iterate through the array and check whether there exists some number that appears for more than n times in the array.If there exists any such element, we should delete its extra occurrences to limit its occurrence to at most num.For example, if the input to the function is −Inputconst arr = [4, 1, 3, 1, 4, 1, 3, 4, 2]; ... Read More

1K+ Views
To convert an array to a phone number string in JavaScript can be done by formatting the array elements into the desired phone number pattern. Following are the steps to learn how to convert array to phone number string in Javascript − Ensure that the array has the correct number of elements (usually 10 for a standard phone number). Join the elements of the array into a single string. Format the string into the desired phone number pattern, such as (XXX) XXX-XXXX. Let us understand through ... Read More

559 Views
ProblemWe are required to write a JavaScript function that takes in an array of positive integers, arr, as the first and the only argument.Our function should sort the input array in such a way that the number that have the highest digit sum comes first followed by the numbers with lesser digit sums.For example, if the input to the function is −Inputconst arr = [5, 34, 1, 13, 76, 8, 78, 101, 57, 565];Outputconst output = [565, 78, 76, 57, 8, 34, 5, 13, 101, 1];Output ExplanationBecause 565 have the highest digit sum of 16, followed by 78 and 76 ... Read More

327 Views
ProblemWe are required to write a JavaScript function that takes in a string of mathematical expressions, str, as the first and the only argument.The task of our function is to remove parentheses from the expression keeping the operations and operands in place.For example, if the input to the function is −Inputconst str = 'u-(v-w-(x+y))-z';Outputconst output = 'u-v+w+x+y-z';ExampleFollowing is the code − Live Democonst str = 'u-(v-w-(x+y))-z'; const removeParentheses = (str = '') => { let stack = [] let lastSign = '+' for (let char of str) { if (char === '(' ... Read More

210 Views
ProblemWe are required to write a JavaScript function that takes in a number, num, as the first and the only argument.Our function should return the number of special steps needed to obtain a palindrome. The special step is: "reverse the digits, and add to the original number". If the resulting number is not a palindrome, repeat the procedure with the sum until the resulting number is a palindrome.For example, if the input to the function is −Inputconst num = 87;Outputconst output = 4;Output ExplanationBecause the steps involved are −87 + 78 = 165; 165 + 561 = 726; 726 + ... Read More
589 Views
Exploring sophisticated algorithms is key to unlocking the true potential of JavaScript programming, particularly when it comes to solving complex computational challenges. Among these algorithms, Kadane's algorithm stands out as a formidable tool for efficiently finding the maximum sum of subarrays within an array. This remarkable technique allows developers to optimize their code and enhance the performance of their applications when dealing with large data sets. In this article, we delve into the intricacies of Kadane's algorithm, unveiling its inner workings and showcasing its efficacy in tackling the task of identifying the maximum sum of subarrays in JavaScript. By grasping ... Read More