AmitDiwan has Published 10744 Articles

Greater possible digit difference of a number in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 09:07:04

172 Views

We are required to write a JavaScript function that takes in a number. Then the function should return the greatest difference that exists between any two digits of the number.In other words, the function should simply return the difference between the greatest and the smallest digit present in it.For example:If ... Read More

Picking all the numbers present in a string in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 09:03:15

142 Views

We are required to write a JavaScript function that takes in a string that contains some one-digit numbers in between and the function should return the sum of all the numbers present in the string.ExampleThe code for this will be −const str = 'uyyudfgdfgf5jgdfj3hbj4hbj3jbb4bbjj3jb5bjjb5bj3'; const sumNum = str => { ... Read More

Addition multiplication ladder in an array in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 09:00:59

155 Views

We are required to write a JavaScript function that takes in an array of numbers and returns the alternative multiplicative sum of the elements.For example: If the array is −const arr = [1, 2, 3, 4, 5, 6, 7];Then the output should be calculated like this −1*2+3*4+5*6+7 2+12+30+7And the output ... Read More

Object to Map conversion in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 08:59:02

188 Views

Suppose, we have an object like this −const obj = {    name: "Jai",    age: 32,    occupation: "Software Engineer",    address: "Dhindosh, Maharasthra",    salary: "146000" };We are required to write a JavaScript function that takes in such an object with key value pairs and converts it into ... Read More

Converting multi-dimensional array to string in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 08:57:16

1K+ Views

We are required to write a JavaScript function that takes in a nested array of literals and converts it to a string by concatenating all the values present in it to the string. Moreover, we should append a whitespace at the end of each string element while constructing the new ... Read More

ASCII sum difference of strings in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 08:53:55

633 Views

ASCII Code:ASCII is a 7-bit character code where every single bit represents a unique character. Every English alphabet has a unique decimal ascii code.We are required to write a function that takes in two strings and calculates their ascii scores (i.e., the sum of ascii decimal of each character of ... Read More

Prime numbers within a range in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 08:51:24

690 Views

We are required to write a JavaScript function that takes in two numbers, say, a and b and returns the total number of prime numbers between a and b (including a and b, if they are prime).For example: If a = 21, and b = 38.The prime numbers between them ... Read More

Removing first k characters from string in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 08:49:16

172 Views

We are required to write a JavaScript function that takes in a string and a number, say k and returns another string with first k characters removed from the string.For example: If the original string is −const str = "this is a string"and, n = 4then the output should be ... Read More

Smart concatenation of strings in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 08:43:22

171 Views

We are required to write a JavaScript function that takes in two strings and concatenates the second string to the first string.If the last character of the first string and the first character of the second string are the same then we have to omit one of those characters.ExampleThe code ... Read More

Check for perfect square in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Oct-2020 08:41:47

1K+ Views

We are required to write a JavaScript function that takes in a number and returns a boolean based on the fact whether or not the number is a perfect square.Examples of perfect square numbers −Some perfect square numbers are −144, 196, 121, 81, 484ExampleThe code for this will be −const ... Read More

Advertisements