AmitDiwan has Published 10744 Articles

Binary array to corresponding decimal in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:37:53

343 Views

ProblemWe are required to write a JavaScript function that takes in a binary array (consisting of only 0 and 1).Our function should first join all the bits in the array and then return the decimal number corresponding to that binary.ExampleFollowing is the code − Live Democonst arr = [1, 0, 1, ... Read More

Finding distance between two points in a 2-D plane using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:37:06

400 Views

ProblemWe are required to write a JavaScript function that takes in two objects both having x and y property specifying two points in a plane.Our function should find and return the distance between those two points.ExampleFollowing is the code − Live Democonst a = {x: 5, y: -4}; const b = ... Read More

Finding astrological signs based on birthdates using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:33:47

1K+ Views

ProblemWe are required to write a JavaScript function that takes in a date object. And based on that object our function should return the astrological sign related to that birthdate.ExampleFollowing is the code − Live Democonst date = new Date(); // as on 2 April 2021 const findSign = (date) => ... Read More

Problem Can we fit remaining passengers in the bus using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:26:13

271 Views

ProblemWe are required to write a JavaScript function that takes in three parameters −cap − is the amount of people the bus can hold excluding the driver.on − is the number of people on the bus excluding the driver.wait − is the number of people waiting to get on to ... Read More

DNA to RNA conversion using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:25:34

864 Views

DNA And RNA RelationDeoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T').Ribonucleic acid, RNA, is the primary messenger molecule in cells. RNA differs slightly from DNA its chemical structure and ... Read More

Returning array of natural numbers between a range in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:24:41

187 Views

ProblemWe are required to write a JavaScript function that takes in an array of two numbers [a, b] (a {    if(lower > upper){       return [];    };    const res = [];    for(let i = lower; i

Returning the nth even number using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:23:40

597 Views

ProblemWe are required to write a JavaScript function that takes in a number n. And our function should simply return the nth even number in natural numbers.ExampleFollowing is the code − Live Democonst num = 67765; const nthEven = (num = 1) => {    const next = num * 2; ... Read More

Replacing digits to form binary using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:23:04

547 Views

ProblemWe are required to write a JavaScript function that takes in a string of digits. Our function should replace any digit below 5 with '0' and any digit 5 and above with '1' and return the resulting string.ExampleFollowing is the code − Live Democonst str = '262355677834342'; const convert = (str ... Read More

Checking existence of all continents in array of objects in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:19:26

141 Views

ProblemWe are required to write a JavaScript function that takes in an array of objects that contains data about the continent of belonging for some people.Our function should return true if it finds six different continents in the array of objects, false otherwise.ExampleFollowing is the code − Live Democonst people = ... Read More

Finding average age from array of Objects using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:17:43

1K+ Views

ProblemWe are required to write a JavaScript function that takes in an object that contains data about some people.Our function should simply find the average of the age property for those people.ExampleFollowing is the code − Live Democonst people = [    { fName: 'Ashish', age: 23 },    { fName: ... Read More

Advertisements