AmitDiwan has Published 10740 Articles

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

AmitDiwan

AmitDiwan

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

421 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

293 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

903 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

208 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

622 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

569 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

151 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

Summing array of string numbers using JavaScript

AmitDiwan

AmitDiwan

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

765 Views

ProblemWe are required to write a JavaScript function that takes in an array that contains integers and string numbers.Our function should sum all the integers and string numbers together to derive a new number and return that number.ExampleFollowing is the code − Live Democonst arr = [67, 45, '34', '23', 4, ... Read More

Advertisements