AmitDiwan has Published 10744 Articles

Finding the only out of sequence number from an array using JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:48:34

467 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers. The array is sorted in ascending / increasing order and only one element in the array is out of order.Our function should find and return that element.ExampleFollowing is the code −const arr = [1, 2, ... Read More

Counting the number of letters that occupy their positions in the alphabets for array of strings using JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:48:14

306 Views

ProblemWe are required to write a JavaScript function that takes in an array of strings of english lowercase alphabets.Our function should map the input array to an array whose corresponding elements are the count of the number of characters that had the same 1-based index in the index as their ... Read More

Breaking a string into chunks of defined length and removing spaces using JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:47:45

258 Views

ProblemWe are required to write a JavaScript function that takes in a string sentence that might contain spaces as the first argument and a number as the second argument.Our function should first remove all the spaces from the string and then break the string into a number of chunks specified ... Read More

Finding the count of numbers divisible by a number within a range using JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:45:22

355 Views

ProblemWe are required to write a JavaScript function that takes in a range of two integers as the first argument and a number as the second argument.Our function should find all the numbers divisible by the input number in the specified range and return their count.ExampleFollowing is the code − Live ... Read More

Constructing an array of first n multiples of an input number in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:44:45

371 Views

ProblemWe are required to write a JavaScript function that takes in two numbers, let say m and n.Our function should construct and return an array of first n natural multiples of m.ExampleFollowing is the code − Live Democonst m = 6; const n = 14; const firstNMultiple = (m = 1, ... Read More

Finding the character with longest consecutive repetitions in a string and its length using JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:44:26

923 Views

ProblemWe are required to write a JavaScript function that takes in a string. Our function should return an array of exactly two elements the first element will be characters that makes the most number of consecutive appearances in the string and second will be its number of appearances.ExampleFollowing is the ... Read More

Returning an array containing last n even numbers from input array in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:43:44

172 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers as the first argument and a number as the second argument.Our function should pick and return an array of last n even numbers present in the input array.ExampleFollowing is the code − Live Democonst arr = ... Read More

Finding two numbers given their sum and Highest Common Factor using JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:43:25

225 Views

ProblemWe are required to write a JavaScript function that takes in two numbers. The first number represents the sum of two numbers and second represents their HCF (GCD or Greatest Common Divisor).Our function should find and return those two numbers.ExampleFollowing is the code − Live Democonst sum = 12; const gcd ... Read More

Repeating each character number of times their one based index in a string using JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:42:34

546 Views

ProblemWe are required to write a JavaScript function that takes in a string of english lowercase alphabets.Our function should construct a new string in which each character is repeated the number of times their 1-based index in the string in capital case and different character sets should be separated by ... Read More

Finding array number that have no matching positive or negative number in the array using JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Apr-2021 09:36:22

171 Views

ProblemWe are required to write a JavaScript function that takes in an array of integers. For each number in the array there will also be its negative or positive compliment present in the array, but for exactly one number, there will be no compliment.Our function should find and return that ... Read More

Advertisements