AmitDiwan has Published 10744 Articles

Counting steps to make number palindrome in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 10:20:07

209 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 return the number of special steps needed to obtain a palindrome. The special step is: "reverse the digits, and add to the original number". If the resulting ... Read More

Breaking camelCase syntax in JavaScript

AmitDiwan

AmitDiwan

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

255 Views

ProblemWe are required to write a JavaScript function that takes in a camelCase string, str as the first and the only argument.Our function should construct and return a new string that splits the input string using a space between words.For example, if the input to the function is −Inputconst str ... Read More

Finding the final direction of movement in JavaScript

AmitDiwan

AmitDiwan

Updated on 22-Apr-2021 09:54:02

344 Views

ProblemWe are required to write a JavaScript function that takes in an array of single characters, arr, as the first and the only argument.The array can contain of only 4 characters, they are −‘N’ → stands for North direction‘S’ → stands for South direction‘W’ → stands for West direction‘E’ → ... Read More

Removing comments from array of string in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Apr-2021 13:17:35

332 Views

ProblemWe are required to write a JavaScript function that takes in array of strings, arr, as the first argument and an array of special characters, starters, as the second argument.The starter array contains characters that can start a comment. Our function should iterate through the array arr and remove all ... Read More

Finding all peaks and their positions in an array in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Apr-2021 13:13:06

575 Views

Build UpSuppose we have the following array in JavaScript −const arr = [4, 3, 4, 7, 5, 2, 3, 4, 3, 2, 3, 4];If we plot the points of this array on y-axis with each adjacent point being unit distance away on x-axis, the graph will look like this −This ... Read More

Finding the just bigger number formed by same digits in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Apr-2021 12:58:39

70 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 find and return a number such that it contains only and all the digits of the input number and is just bigger than the input numberIf there ... Read More

Creating a chained operation class in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Apr-2021 12:47:52

115 Views

ProblemWe are supposed to create a user defined data type Streak in JavaScript that can be chained to any extent with value and operations alternativelyThe value can be one of the following strings −→ one, two three, four, five, six, seven, eight, nineThe operation can be one of the following strings −→ ... Read More

Finding minimum time difference in an array in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Apr-2021 12:41:47

409 Views

ProblemWe are required to write a JavaScript function that takes in an array of 24-hour clock time points in "Hour:Minutes" format. Our function should find the minimum minutes difference between any two time points in the array.For example, if the input to the function is −const arr = ["23:59", "00:00"];Then ... Read More

Reversing and preserving spaces in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Apr-2021 12:37:24

337 Views

ProblemWe are required to write a JavaScript function that takes in a sentence string, str, as the first and the only argument.Our function is supposed to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.For example, if the input to ... Read More

Find and return the longest length of set in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Apr-2021 12:32:33

224 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the first and the only argument.The array, arr, of length N contains all integers from 0 to N-1. Our function is supposed to find and return the longest length of set S, where ... Read More

Advertisements