Challenge 7

Get the Navigation Outline of a Google Doc as a Table


Google Docs creates a navigation outline on the left sidetray that is useful for navigating a document. Your employer wants to see a copy of this outline in a Google Sheet so that they can more easily get a sense for the size and structure of the document.


Using JavaScript in the Inspector Console, get the titles of a document's navigation outline items as a table that can be copy/pasted to a spreadsheet.


Here's an example function that could work:

// Find all elements with the class "navigation-item"
const navigationItems = document.querySelectorAll('.navigation-item');

// Create an array to store the text content of the navigation items
const navigationText = [];

// Iterate through the elements and add their text content to the array
navigationItems.forEach((item) => {
        'Navigation Item': item.textContent.trim()

// Display the results in a table in the console

This content is provided to you freely by EdTech Books.

Access it online or download it at