- 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 10710 Articles for Web Development
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
244 Views
ProblemWe are required to write a JavaScript function that takes in a number, num, as the first and the only argumentOur function should do two thingsFirst of all, it should check whether the number is prime with 10 or not, if its not, we should return -1 (a number is prime with any other number if the only common factor they share is 1).If the number is prime with 10, then we should return the length of the decimal part which repeats itself, when that very number divides 1.For example, if the input to the function is −Inputconst num = ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
59 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 first join the numbers present in the array and find the single number represented by the array and then return a new array that represents the number which is greater than the input array number by a magnitude of 1.For example, if the input to the function is −Inputconst arr = [6, 7, 3, 9];Outputconst output = [6, 7, 4, 0];Output ExplanationBecause the number represented by input array is 6739 and the required number ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
424 Views
ProblemWe are required to write a JavaScript function that takes in a string of uppercase English alphabets, str, as the first and the only argument.Consider the following mapping between English and Greek letters −A=α (Alpha) B=β (Beta) D=δ (Delta) E=ε (Epsilon) I=ι (Iota) K=κ (Kappa) N=η (Eta) O=θ (Theta) P=ρ (Rho) R=π (Pi) T=τ (Tau) U=μ (Mu) V=υ (Upsilon) W=ω (Omega) X=χ (Chi) Y=γ (Gamma)For all the alphabets that have a Greek mapping our function should create a new string in which the English letter is replaced by corresponding Greek letter and if there exists no mapping we should persist ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
506 Views
ProblemWe are required to write a JavaScript function that takes in an array of integers, arr, as the first and the only argument.The array either consists of all even numbers and just one odd number or consists of all odd numbers and just one even number. Our function should return this one different element from the array.For example, if the input to the function is −Inputconst arr = [5, 9, 7, 11, 34, 23, 77];Outputconst output = 34;Output ExplanationBecause the array consists of all odd numbers but 34 which is even.ExampleFollowing is the code − Live Democonst arr = [5, 9, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
84 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
110 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
440 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
127 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
160 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
ProblemWe are required to write a JavaScript function that takes in an array of exactly 10 positive integers, arr, as the first and the only argument.Our function should then return a string which is in the format of a phone number string.For example, if the input to the function is −Inputconst arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0];Outputconst output = '(987) 654-3210';ExampleFollowing is the code − Live Democonst arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]; const createNumber = (arr = []) => { let res = ''; arr = arr.map(String); res += `(${arr[0]+arr[1]+arr[2]}) `; res += `${arr[3] + arr[4] + arr[5]}-`; res += arr[6] + arr[7] + arr[8] + arr[9]; return res; }; console.log(createNumber(arr));Output(987) 654-3210