Created
June 19, 2017 14:39
-
-
Save JoeShep/e4664c1ea627b7ad7320e86f3dce2fa4 to your computer and use it in GitHub Desktop.
An ES6 module; alternative to iife syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
let planetsArr = []; | |
let dwarfPlanets = []; | |
let planetsLandedOn = 0; | |
planetsArr.push("mercury", "Venus", "earth", "MArs", "jupiter", "saturn", "uranus", "Neptune"); | |
let planets = Object.create(null); | |
planets.setPlanetsLandedOn = function(count) { | |
if (count < 0 || count > planetsArr.length) { | |
throw `I don't think so, bud. There are only ${planetsArr.length} planets`; | |
} else { | |
planetsLandedOn = count; | |
} | |
} | |
planets.lowercasePlanets = function() { | |
planetsArr = planetsArr.map( function(planet) { | |
return planet.toLowerCase(); | |
}); | |
} | |
planets.addDwarfPlanet = function(planetoid) { | |
dwarfPlanets.push(planetoid); | |
} | |
planets.getPlanets = function() { | |
return planetsArr; | |
} | |
window.SolarSystem = window.SolarSystem || {}; | |
SolarSystem.Planets = planets; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment