Skip to content

Instantly share code, notes, and snippets.

@wcalderipe
Created July 12, 2017 00:16
Show Gist options
  • Save wcalderipe/71da2974cfb43acbe1802779c2ac3cff to your computer and use it in GitHub Desktop.
Save wcalderipe/71da2974cfb43acbe1802779c2ac3cff to your computer and use it in GitHub Desktop.
const flightBuilder = () => {
let flight = {}
const builder = {
withFlightCode: (flightCode) => {
flight.flightCode = flightCode
return builder
},
withStops: (stops) => {
flight.stops = stops
return builder
},
build: () => {
return flight
}
}
return builder
}
console.log(flightBuilder().withFlightCode('XL1234').withStops(2).build())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment