Skip to content

Instantly share code, notes, and snippets.

@ulisses-cruz
Created December 7, 2021 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulisses-cruz/47829f3b33604b9a4476be420ad935b9 to your computer and use it in GitHub Desktop.
Save ulisses-cruz/47829f3b33604b9a4476be420ad935b9 to your computer and use it in GitHub Desktop.

This week’s question: (from Cassidy's newsletter)

You have to order wrapping paper for presents. Given the length, width, and height of the boxes you need to wrap, return the number of square feet (or whatever units you want) of wrapping paper you need to order. Extra credit: allow for other shapes of presents and their dimensions!

Example:

$ wrap(2, 3, 4)
$ 52 square feet

My solution:

function wrap(length, width, height) {
  return length * width  * 2 +
    	 width  * height * 2 +
    	 height * length * 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment