- 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 8894 Articles for Front End Technology
112 Views
In the realm of JavaScript programming, the ability to calculate the value of (m) to the power 1/n holds significant importance, as it enables developers to perform complex mathematical operations with precision and efficiency. Harnessing the power of JavaScript's computational capabilities, this article dives into the intricacies of calculating such exponential values. By exploring the underlying algorithms and employing rarely used mathematical functions, we will equip developers with the knowledge and tools necessary to seamlessly perform these calculations in their JavaScript programs. Join us on this enlightening journey as we unravel the secrets of computing (m) to the power 1/n, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
614 Views
ProblemWe are required to write a JavaScript function that takes in a string str. Our function should construct a new string that contains only the unique characters from the input string and remove all occurrences of duplicate characters.ExampleFollowing is the code − Live Democonst str = 'hey there i am using javascript'; const removeAllDuplicates = (str = '') => { let res = ''; for(let i = 0; i < str.length; i++){ const el = str[i]; if(str.indexOf(el) === str.lastIndexOf(el)){ res += el; continue; }; }; return res; }; console.log(removeAllDuplicates(str));OutputFollowing is the console output −Ymungjvcp
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
253 Views
ProblemWe are required to write a JavaScript function that takes in a string that contains numbers separated by spaces.Our function should return a string that contains only the greatest and the smallest number separated by space.Inputconst str = '5 57 23 23 7 2 78 6';Outputconst output = '78 2';Because 78 is the greatest and 2 is the smallest.ExampleFollowing is the code − Live Democonst str = '5 57 23 23 7 2 78 6'; const pickGreatestAndSmallest = (str = '') => { const strArr = str.split(' '); let creds = strArr.reduce((acc, val) => { let { greatest, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
73 Views
ProblemWe are required to write a JavaScript function that takes in a sentence of words and a number. The function should return an array of all words greater than the length specified by the number.Inputconst str = 'this is an example of a basic sentence'; const num = 4;Outputconst output = [ 'example', 'basic', 'sentence' ];Because these are the only three words with length greater than 4.ExampleFollowing is the code − Live Democonst str = 'this is an example of a basic sentence'; const num = 4; const findLengthy = (str = '', num = 1) => { const strArr ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
446 Views
ProblemWe are required to write a JavaScript function that takes in an array of mixed data types. Our function should return an object that contains data type names as key and their value as array of elements of that specific data type present in the array.ExampleFollowing is the code − Live Democonst arr = [1, 'a', [], '4', 5, 34, true, undefined, null]; const groupDataTypes = (arr = []) => { const res = {}; for(let i = 0; i < arr.length; i++){ const el = arr[i]; const type = typeof el; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
515 Views
ProblemWe can check for a number to be divisible by 7 if it is of the form 10a + b and a - 2b is divisible by 7.We continue to do this until a number known to be divisible by 7 is obtained; we can stop when this number has at most 2 digits because we are supposed to know if a number of at most 2 digits is divisible by 7 or not.We are required to write a JavaScript function that takes in a number and return the number of such steps required to reduce the number to a ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
434 Views
ProblemWe are required to write a JavaScript function that takes in a number and returns the count of its divisor.Inputconst num = 30;Outputconst output = 8;Because the divisors are −1, 2, 3, 5, 6, 10, 15, 30ExampleFollowing is the code − Live Democonst num = 30; const countDivisors = (num = 1) => { if (num === 1) return num let divArr = [[2, 0]] let div = divArr[0][0] while (num > 1) { if (num % div === 0) { for (let i = 0; divArr.length; i++) { if (divArr[i][0] === div) { divArr[i][1] += 1 break } else { if (i === divArr.length - 1) { divArr.push([div, 1]) break } } } num /= div } else { div += 1 } } for (let i = 0; i < divArr.length; i++) { num *= divArr[i][1] + 1 } return num } console.log(countDivisors(num));Output8
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
328 Views
ProblemWe are required to write a JavaScript function that takes in the number of second and return the number of hours and number of minutes contained in those seconds.Inputconst seconds = 3601;Outputconst output = "1 hour(s) and 0 minute(s)";ExampleFollowing is the code − Live Democonst seconds = 3601; const toTime = (seconds = 60) => { const hR = 3600; const mR = 60; let h = parseInt(seconds / hR); let m = parseInt((seconds - (h * 3600)) / mR); let res = ''; res += (`${h} hour(s) and ${m} minute(s)`) return res; }; console.log(toTime(seconds));Output"1 hour(s) and 0 minute(s)"
106 Views
Exploring the intricate realm of JavaScript, one encounters various programming challenges that demand innovative solutions. Among these, the ability to return a reverse array of integers emerges as a fundamental yet significant topic. Understanding how to manipulate arrays in JavaScript is essential for developers seeking to enhance their coding prowess. In this enlightening article, we shall embark on a journey to unravel the intricacies of returning a reverse array of integers using JavaScript. By delving into the depths of this subject matter and employing lesser-known methods, we shall empower developers with the knowledge and skills to conquer array manipulation challenges ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
232 Views
ProblemWe are required to write a JavaScript function that takes in a sequence of valid words and a string. Our function should test if the string is made up by one or more words from the array.Inputconst arr = ['love', 'coding', 'i']; const str = 'ilovecoding';Outputconst output = true;Because the string can be formed by the words in the array arr.ExampleFollowing is the code − Live Democonst arr = ['love', 'coding', 'i']; const str = 'ilovecoding'; const validString = (arr = [], str) => { let arrStr = arr.join(''); arrStr = arrStr .split('') .sort() .join(''); ... Read More