- 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
188 Views
ProblemWe are required to write a JavaScript function that takes in a string of English alphabets. Our function should construct a new string and every consonant should be pushed forward 9 places through the alphabet. If they pass 'z', start again at 'a'. And every vowel should be pushed by 5 places.ExampleFollowing is the code − Live Democonst str = 'sample string'; const moveWords = (str = '') => { str = str.toLowerCase(); const legend = 'abcdefghijklmnopqrstuvwxyz'; const isVowel = char => 'aeiou'.includes(char); const isAlpha = char => legend.includes(char); let res = ''; for(let i ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
205 Views
ProblemWe are required to write a JavaScript function that takes in a string. Our function should convert the string according to following rules −The words should be Caps, Every word should end with '!!!!', Any letter 'a' or 'A' should become '@', Any other vowel should become '*'.ExampleFollowing is the code − Live Democonst str = 'ban censored words'; const maskWords = (str = '') => { let arr=str.split(' '); const res=[] for (let i=0; i
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
119 Views
ProblemWe are required to write a JavaScript function that takes in a string of some mathematical operation and return its literal wording.ExampleFollowing is the code −const str = '5 - 8'; const convertToWords = (str = '') => { const o = { "+" : "Plus", "-" : "Minus", "*" : "Times", "/" : "Divided By", "**" : "To The Power Of", "=" : "Equals", "!=" : "Does Not Equal", } const n = { ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
203 Views
ProblemWe are required to write a JavaScript function that takes in two strings. The first string specifies the user name and second the owner name.If the user and owner are the same our function should return ‘hello master’, otherwise our function should return ‘hello’ appended with the name of that user.ExampleFollowing is the code − Live Democonst name = 'arnav'; const owner = 'vijay'; function greet (name, owner) { if (name === owner){ return 'Hello master'; } return `Hello ${name}`; }; console.log(greet(name, owner));OutputHello arnav
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
491 Views
ProblemWe are required to write a JavaScript function that takes in an array of numbers of length at least three.Our function should simply return the third smallest number from the array.ExampleFollowing is the code − Live Democonst arr = [6, 7, 3, 8, 2, 9, 4, 5]; const thirdSmallest = () => { const copy = arr.slice(); for(let i = 0; i < 2; i++){ const minIndex = copy.indexOf(Math.min(...copy)); copy.splice(minIndex, 1); }; return Math.min(...copy); }; console.log(thirdSmallest(arr));Output4
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
103 Views
ProblemWe are required to write a JavaScript function that takes in a string that contains only ‘A’, ‘B’ and ‘C’. Our function should find the minimum number of characters needed to be removed from the string so that the characters in each pair of adjacent characters are different.ExampleFollowing is the code − Live Democonst str = "ABBABCCABAA"; const removeLetters = (str = '') => { const arr = str.split('') let count = 0 for (let i = 0; i < arr.length; i++) { if (arr[i] === arr[i + 1]) { count += 1 arr.splice(i, 1) i -= 1 } } return count } console.log(removeLetters(str));Output3
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
131 Views
ProblemWe are required to write a JavaScript function that takes in a string of English alphabets.Our function should count the number of rings present in the string.O', 'b', 'p', 'e', 'A', etc. all have one rings whereas 'B' has 2ExampleFollowing is the code − Live Democonst str = 'some random text string'; function countRings(str){ const rings = ['A', 'D', 'O', 'P', 'Q', 'R', 'a', 'b', 'd', 'e', 'g', 'o', 'p', 'q']; const twoRings = ['B']; let score = 0; str.split('').map(x => rings.includes(x) ? score++ : twoRings.includes(x) ? score = score + 2 : x ); return score; } console.log(countRings(str));Output7
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
565 Views
ProblemWe are required to write a JavaScript function that takes in one positive three-digit integer and rearranges its digits to get the maximum possible number.ExampleFollowing is the code − Live Democonst num = 149; const maxRedigit = function(num) { if(num < 100 || num > 999) return null return +num .toString() .split('') .sort((a, b) => b - a) .join('') }; console.log(maxRedigit(num));Output941
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
306 Views
ProblemWe are required to write a JavaScript function that takes in an array of strings. Our function should create combinations by combining all possible n consecutive strings in the array and return the longest such string that comes first.ExampleFollowing is the code − Live Democonst arr = ["zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail"]; const num = 2; function longestConsec(strarr, k) { if (strarr.length == 0 || k > strarr.length || k longStr.length ){ longStr = newStr.join(''); } } return longStr; } console.log(longestConsec(arr, num));Outputabigailtheta
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
81 Views
ProblemTwo words can mesh together if the ending substring of the first is the starting substring of the second. For instance, robinhood and hoodie can mesh together.We are required to write a JavaScript function that takes in an array of strings. If all the words in the given array mesh together, then our function should return the meshed letters in a string, otherwise we should return an empty string.ExampleFollowing is the code − Live Democonst arr = ["allow", "lowering", "ringmaster", "terror"]; const meshArray = (arr = []) => { let res = ""; for(let i = 0; i < ... Read More