Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

convert given seconds to space age on all planets of our solar system

//Convert given seconds to space age on all planets of our solar system

const spaceAge = (seconds) => {
    const secondsInDays = (((seconds/60)/60)/24)
	const earthYearInDyas = 365.25
    const yearsInAllPlanets = {
		Mercury: 0,
		Venus: 0,
		Earth: 0,
		Mars: 0,
		Jupiter: 0,
		Saturn: 0,
		Uranus: 0,
		Neptune: 0,
	}

    const earthYearInDays = {
		Mercury: earthYearInDyas*0.2408467,
		Venus: earthYearInDyas*0.61519726,
		Earth: earthYearInDyas,
		Mars: earthYearInDyas*1.8808158,
		Jupiter: earthYearInDyas*11.862615,
		Saturn: earthYearInDyas*29.447498,
		Uranus: earthYearInDyas*84.016846,
		Neptune: earthYearInDyas*164.79132,
	}

    Object.keys(yearsInAllPlanets).forEach(planet => {
        yearsInAllPlanets[planet] = Number((secondsInDays/earthYearInDays[planet]).toFixed(2))
    })

	return yearsInAllPlanets
}

console.log(spaceAge(Math.round(Math.random() * 99999999)))
Comment

PREVIOUS NEXT
Code Example
Typescript :: Decrypt 
Typescript :: what to do when testing new feature with limited information 
Typescript :: nest js config from yaml 
Typescript :: The Apple I had a built-in video terminal, sockets for __________ kilobytes of onboard random access memory (RAM), a keyboard, and a cassette board meant to work with regular cassette recorders. 
Typescript :: The softness of a spot lights edge is controlled by penumbra angle, value gives perfect hard edge: 
Typescript :: Define a function sum_two_gr with three arguments returning the sum of the greatest two python 
Typescript :: how to save plots into raster format from r 
Typescript :: if confidence level increases what happens to width 
Typescript :: how to get date from Sun Dec 10 1995 00:00:00 GMT+0530 (India Standard Time) 
Typescript :: How to check that tuple A contains all elements of tuple B python? 
Typescript :: python list comports on windows 
Typescript :: consisting either of digits only or Latin letters 
Typescript :: useHorizontalScroll react 
Typescript :: objects all django what is returned 
Typescript :: fieldmatch cannot be resolved to a type 
Typescript :: custom function with condition in google sheet 
Typescript :: Passing a generic function in as a callback in Typescript 
Typescript :: add optional parameters javascript or typescript function 
Typescript :: ts repeat string 
Typescript :: flutter: Error: google_fonts was unable to load font LobsterTwo-Bold because the following exception occured: 
Typescript :: apply limit to fetch number of documents firebase firestore 
Typescript :: angular jasmine tobe empty array 
Typescript :: check if element exists in array java 
Typescript :: online ts compiler 
Typescript :: jquery tscroll up 
Typescript :: how to make auto conversion of blogger texts with fonts installed in blog theme 
Cpp :: c++ code to print hello world 
Cpp :: min priority queue c++ 
Cpp :: avrational compare 
Cpp :: como medir tiempo de ejecucion cpp 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =