Project: Christmas Turkey Pre-Orders

The turkey page is on main, and it lists the pickup days and the sizes. Two things a customer needs are still missing, though, which is why the turkey issue is still open. The page doesn’t say when orders close for each pickup day or what each size costs. Nobody wants to call on December 20 and find out that orders for the 22nd closed the evening before.

This time, you’ll make the change on your own, from a fresh branch to a merged pull request and a clean report. You’ll write the page’s logic, display the results on the page, and take the change through every habit from this course. Start with the brief, which says what the page needs.

Read the Brief

The brief describes the result and leaves the steps to you, so read it the way you’d read an issue from a team.

The store follows two rules:

  • Pre-orders close at 6 p.m., three days before pickup. For a turkey picked up on Tuesday, December 22, the last chance to order is Saturday, December 19, at 6 p.m. in the store’s local time. The brief treats your computer’s time zone as the store’s, so the Date you return is 6 p.m. as your computer shows it. A real cutoff for every customer would need the code to pick the store’s time zone.

  • A turkey costs its weight times the price per pound. The price in src/data/turkey.js is 249 cents a pound. The result is in whole cents, rounded to the nearest cent, because a turkey on the scale isn’t always a whole number of pounds.

Put the rules in a new file, src/lib/turkey.js, as two exported functions:

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.