AmitDiwan has Published 10744 Articles

Joining two strings with two words at a time - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:14:35

159 Views

We are required to write a JavaScript function that takes in two strings, creates and returns a new string with first two words of first string, next two words of second string, then first, then second and so on.For example −If the strings are −const str1 = 'Hello world'; const ... Read More

Returning the second most frequent character from a string (including spaces) - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:13:24

399 Views

We are required to write a JavaScript function that takes in a string and returns the character which makes second most appearances in the string.ExampleFollowing is the code −const str = 'Hello world, I have never seen such a beautiful weather in the world'; const secondFrequent = str => { ... Read More

Mapping unique characters of string to an array - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:12:26

416 Views

We are required to write a JavaScript function that takes in a string and starts mapping its characters from 0. And every time the function encounters a unique (non-duplicate) character, it should increase the mapping count by 1 otherwise map the same number for duplicate characters.For example − If the ... Read More

Checking semiprime numbers - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:11:12

389 Views

We are required to write a JavaScript function that takes in a number and the function establishes if the provided number is a semiprime or not.SemiprimeA semiprime number is that number which is a special type of composite number that is a product of two prime numbers. For example: 6, ... Read More

Sorting digits of all the number of array - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:10:00

782 Views

We are required to write a JavaScript function that takes in an array of numbers and reorders the digit of all the numbers internally in a specific order (lets say in ascending order for the sake of this problem).For example − If the array is −const arr = [543, 65, ... Read More

Counting the number of redundant characters in a string - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:08:49

278 Views

We are required to write a JavaScript function that takes in a string and returns the count of redundant characters in the string.For example − If the string is −const str = 'abcde'Then the output should be 0If the string is −const str = 'aaacbfsc';Then the output should be 3ExampleFollowing ... Read More

Checking progressive array - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:07:43

204 Views

We are required to write a JavaScript function that takes in an array of strings, ordered by ascending length.The function should return true if, for each pair of consecutive strings, the second string can be formed from the first by adding a single letter either at the beginning or end.For ... Read More

Returning poker pair cards - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:02:15

158 Views

We are required to write a function that takes in an array of exactly five elements representing the five cards of a poker player drawn randomly.If the five cards contain at least one pair, our function should return the card number of the highest pair (trivial if there only exists ... Read More

Finding closed loops in a number - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:00:51

483 Views

Other than all being a natural number, the numbers 0, 4, 6, 8, 9 have one more thing in common. All these numbers are formed by or contain at least one closed loop in their shapes.For example, the number 0 is a closed loop, 8 contains two closed loops and ... Read More

Removing last vowel - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 08:59:33

367 Views

We are required to write a JavaScript function that takes in a string and returns a new string with the last vowel of each word removed.For example − If the string is −const str = 'This is an example string';Then the output should be −const output = 'Ths s n ... Read More

Advertisements