AmitDiwan has Published 10744 Articles

Neutralisation of strings - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:51:07

246 Views

We are required to write a JavaScript function that takes in a string that contains only '+' or '-' and we have to return either '+' or '-' based on the whole neutralisation result of the string.Like '++' results to '+' and '--' also results to '+' while '-+' or ... Read More

Checking Oddish and Evenish numbers - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:49:52

254 Views

A number is Oddish if the sum of all of its digits is odd, and a number is Evenish if the sum of all of its digits is even.We are required to write a function that determines whether a number is Oddish or Evenish. We should return true of Oddish ... Read More

Product of two number using HOC - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:48:45

271 Views

HOCHOC or Higher Order Functions in JavaScript are a special type of functions that receives another function as argument or have a function set as their return value or do both. HOC along with closures is a very powerful tool in JavaScript.We are required to write a JavaScript Higher Order ... Read More

Removing 0s from start and end - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:38:09

143 Views

We are required to write a JavaScript function that takes in a number as a string and returns a new number string with all the leading and trailing 0s removedFor example: If the input is −const strNum = '054954000'Then the output should be −const output = '54954'ExampleFollowing is the code ... Read More

Finding special array - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:36:10

541 Views

An array is a special array if −--All the elements at odd indices are odd. --All the elements at even indices are even.We are required to write a JavaScript function that takes in an array and checks if its a special array or not.ExampleFollowing is the code −const arr = ... Read More

Move string capital letters to front maintaining the relative order - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:35:03

312 Views

We are required to write a JavaScript function that takes in a string with uppercase and lowercase letters. The function should return a string with all the uppercase letters moved to front of the string.For example: If the input string is −const str = 'heLLO woRlD';Then the output should be ... Read More

Concatenating variable number of arrays into one - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:33:56

542 Views

We are required to write a JavaScript function that takes in any number of JavaScript arrays and returns one single array with all the values from input arrays concatenated into it.For example − If the input arrays are −[1, 5], [44, 67, 3], [2, 5], [7], [4], [3, 7], [6]Then ... Read More

Array of multiples - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:32:46

930 Views

We are required to write a JavaScript function that takes in two numbers, say m and n, and it returns an array of first n multiples of m.For example − If the numbers are 4 and 6Then the output should be −const output = [4, 8, 12, 16, 20, 24]ExampleFollowing ... Read More

Finding tidy numbers - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:31:44

247 Views

A tidy number is a number whose digits are in non-decreasing order. We are required to write a JavaScript function that takes in a number and checks whether its a tidy number or not.For example −489 is a tidy number 234557 is also a tidy number 34535 is not a ... Read More

Number of smaller and larger elements - JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Sep-2020 09:30:24

418 Views

Suppose, we have an array of literals like this −const arr = [3, 5, 5, 2, 23, 4, 7, 8, 8, 9];We are required to write a JavaScript function that takes in this array and a number, say n, and returns an object representing the count of elements greater than ... Read More

Advertisements