app.js
/*
 * Method that displays the number of orphan planets(no star).
 * Here we use `forEach method` to iterate the array of exoPlanetDataSet objects and displays the number of orphan planets(no star) based on the TypeFlag value. 
 * As per the shared document, for orphan planets(no star) the TypeFlag value is 3.
 * {Arguments}
 * exoPlanetDataSet : array of exoPlanet objects.
 * displays and returns the number of orphan planets(no star).
 */
Method that displays the number of orphan planets(no star).
Here we use `forEach method` to iterate the array of exoPlanetDataSet objects and displays the number of orphan planets(no star) based on the TypeFlag value.
As per the shared document, for orphan planets(no star) the TypeFlag value is 3.
{Arguments}
exoPlanetDataSet : array of exoPlanet objects.
displays and returns the number of orphan planets(no star).
Method that displays the number of orphan planets ( no star ) . Here we use ` forEach method ` to iterate the array of exoPlanetDataSet objects and displays the number of orphan planets ( no star ) based on the TypeFlag value . As per the shared document for orphan planets ( no star ) the TypeFlag value is 3 . { Arguments } exoPlanetDataSet : array of exoPlanet objects . displays and returns the number of orphan planets ( no star ) .
function displayOrphanPlanets(exoPlanetDataSet) {
	let orphan_planet_count = 0; 
	if (exoPlanetDataSet && exoPlanetDataSet.length > 0) {
		Object.keys(exoPlanetDataSet).forEach(key => { 
			if (exoPlanetDataSet[key].TypeFlag && exoPlanetDataSet[key].TypeFlag === 3) { 
				orphan_planet_count++; 
			}
		});
		console.log('The number of orphan planets (no star): ', orphan_planet_count); 
	}
	return orphan_planet_count;
}
function displayOrphanPlanets ( exoPlanetDataSet ) { let orphan_planet_count = 0 ; if ( exoPlanetDataSet && exoPlanetDataSet . length > 0 ) { Object . keys ( exoPlanetDataSet ) . forEach ( key => { if ( exoPlanetDataSet [ key ] . TypeFlag && exoPlanetDataSet [ key ] . TypeFlag === 3 ) { orphan_planet_count ++ ; } } ) ; console . log ( 'The number of orphan planets (no star): ' , orphan_planet_count ) ; } return orphan_planet_count ; }
Method that displays the number of orphan planets(no star).
Method that displays the number of orphan planets ( no star ) .
// Initialize the variable to store the orphan planet count //Iterate the array of exoPlanetDataSet objects // check TypeFlag for undefined or null values and it equals 3 // increment the orphan planet count variable // Display the number of orphan planets(no star) // return the number of orphan planets(no star)