AmitDiwan has Published 10744 Articles

Returning just greater array in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 11:09:42

90 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 ... Read More

Converting alphabets to Greek letters in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 11:08:13

598 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=ρ ... Read More

Returning only odd number from array in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 11:04:20

619 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 ... Read More

Counting possible APs within an array in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 10:59:48

150 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 ... Read More

Returning number of digits in factorial of a number in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 10:58:25

171 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 ... Read More

Array index to balance sums in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 10:55:13

568 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 ... Read More

Encoding string based on character frequency in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 10:50:30

211 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 ... Read More

Limiting elements occurrences to n times in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 10:44:53

236 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 ... Read More

Sorting numbers based on their digit sums in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 10:36:28

558 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 sort the input array in such a way that the number that have the highest digit sum comes first followed by the numbers with ... Read More

Removing parentheses from mathematical expressions in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 10:28:19

324 Views

ProblemWe are required to write a JavaScript function that takes in a string of mathematical expressions, str, as the first and the only argument.The task of our function is to remove parentheses from the expression keeping the operations and operands in place.For example, if the input to the function is ... Read More

Advertisements