app.js
/*
 * Method that displays the timeline with the count of small, medium and large planets discovered.
 * Here we use Set, map, sort and filter methods to get the unique values of DiscoveryYear and count of small, medium and large planets discovered in the respective years by matching with jupiter radii
 * {Arguments}
 * exoPlanetDataSet : array of exoPlanet objects.
 * displays and returns the timeline with the count of small, medium and large planets discovered.
 */
Method that displays the timeline with the count of small, medium and large planets discovered.
Here we use Set, map, sort and filter methods to get the unique values of DiscoveryYear and count of small, medium and large planets discovered in the respective years by matching with jupiter radii
{Arguments}
exoPlanetDataSet : array of exoPlanet objects.
displays and returns the timeline with the count of small, medium and large planets discovered.
Method that displays the timeline with the count of small medium and large planets discovered . Here we use Set map sort and filter methods to get the unique values of DiscoveryYear and count of small medium and large planets discovered in the respective years by matching with jupiter radii { Arguments } exoPlanetDataSet : array of exoPlanet objects . displays and returns the timeline with the count of small medium and large planets discovered .
async function displayPlanetDiscoveryTimeline(exoPlanetDataSet) {
	let timeline = []; 
	if (exoPlanetDataSet && exoPlanetDataSet.length > 0) {
		let unique = [...new Set(exoPlanetDataSet.filter(function (response) {
			if (response.DiscoveryYear === "") {
				return false;
			}
			return true;
		}).map(val => val.DiscoveryYear))];
		unique.sort();
		console.log('\n****************************TimeLine Information grouped by planet size****************************\n');
		unique.forEach(obj => {
			var small_planet_count = exoPlanetDataSet.filter((object) => (object.DiscoveryYear === obj && object.RadiusJpt !== "" && object.RadiusJpt < 1)).length;
			var medium_planet_count = exoPlanetDataSet.filter((object) => (object.DiscoveryYear === obj && object.RadiusJpt >= 1 && object.RadiusJpt < 2)).length;
			var large_planet_count = exoPlanetDataSet.filter((object) => (object.DiscoveryYear === obj && object.RadiusJpt >= 2)).length;
			console.log(`In ${(obj)} we discovered ${(small_planet_count)} small planets, ${(medium_planet_count)} medium planets and ${(large_planet_count)} large planets \n`);
			timeline.push(obj, small_planet_count, medium_planet_count, large_planet_count);
		});
		console.log('\n********************************************************\n');
	}
	return timeline;
}
async function displayPlanetDiscoveryTimeline ( exoPlanetDataSet ) { let timeline = [ ] ; if ( exoPlanetDataSet && exoPlanetDataSet . length > 0 ) { let unique = [ ... new Set ( exoPlanetDataSet . filter ( function ( response ) { if ( response . DiscoveryYear === "" ) { return false ; } return true ; } ) . map ( val => val . DiscoveryYear ) ) ] ; unique . sort ( ) ; console . log ( '\n****************************TimeLine Information grouped by planet size****************************\n' ) ; unique . forEach ( obj => { var small_planet_count = exoPlanetDataSet . filter ( ( object ) => ( object . DiscoveryYear === obj && object . RadiusJpt !== "" && object . RadiusJpt < 1 ) ) . length ; var medium_planet_count = exoPlanetDataSet . filter ( ( object ) => ( object . DiscoveryYear === obj && object . RadiusJpt >= 1 && object . RadiusJpt < 2 ) ) . length ; var large_planet_count = exoPlanetDataSet . filter ( ( object ) => ( object . DiscoveryYear === obj && object . RadiusJpt >= 2 ) ) . length ; console . log ( ` ${ ( obj ) } ${ ( small_planet_count ) } ${ ( medium_planet_count ) } ${ ( large_planet_count ) } \n ` ) ; timeline . push ( obj , small_planet_count , medium_planet_count , large_planet_count ) ; } ) ; console . log ( '\n********************************************************\n' ) ; } return timeline ; }
Method that displays the timeline with the count of small, medium and large planets discovered.
Method that displays the timeline with the count of small medium and large planets discovered .
//Array to store the timeline object  // Identify unique objects based on DiscoveryYear // sort discovery year based on the timeline //Itterate the unique objects //calculate small_planet_count //calculate medium_planet_count //calculate large_planet_count //displays the timeline with the count of small, medium and large planets discovered. //push calculated timeline data to an array //returns the timeline with the count of small, medium and large planets discovered.