Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

Data Drives the Page (Summary)

You’ve finished Data Drives the Page, and Priya’s scorekeeper is done.

First, you added and removed games at the queue’s ends with push(), unshift() and shift(), and took Catan out of the middle with splice(), after checking that indexOf() didn’t return -1. Pushing Carcassonne onto the queue changed the saved queue too, since const saved = queue; gave two arrows to one array.

Next, a click climbed up the page, so one listener on the list handled every row, even Tomás’s.

Then the data became the one source of truth. Last, the code split into three modules.

In the scorekeeper, each click changes the players array, and render() redraws the totals and the leader. Wei scores in round 1. In round 2, Amara scores twice. Undo last round takes round 2 back, so Wei leads again. Remove Wei, and the other three tie at 0, and nobody leads.

What You Can Do Now

You can now keep an app’s data in one place and redraw the page from it, with one listener handling a whole list, and split the app into modules.

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.