JavaScript Functions for Pythonistas (Summary)

Congratulations, you made it to the end of the course! The translator’s quote rules now run in JavaScript and price each quote with whatever options a client ticked. quote-lines.js prints the same three lines as her Python script: Bauer Legal’s €1,116.00 rush job, Café Linde’s €40.00 minimum, and Nordwind GmbH’s 1128.00 for the sheet.

In this course, you learned how to:

  • Return early from a function and read undefined as “not passed, not returned, or not there”
  • Return several results as an array, [fee, days], to destructure, or as an object when they need names
  • Write the default you mean in the parameter list, such as notes = []
  • Name small functions as arrows in a const, knowing that a braced body needs a return, and a returned object needs parentheses: () => ({ total: 0 })
  • Pass functions such as forEmail around and wrap a method call in an arrow
  • Take named options in one object, destructured with defaults and made optional with = {}, keeping one or two required values by position

Keep the Habits That Carry Over

Much of your Python thinking still holds: return and early returns, defaults after an = in the parameter list, and functions as values you can store and pass, as handing forSheet to the Nordwind line showed.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.