> For the complete documentation index, see [llms.txt](https://docs.launchboard.app/cxd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.launchboard.app/cxd/code-trivia-app-1/code-template/template-build-tutorial/6.-load-questions-and-go.md).

# 6. Load Questions and Go

### A Word About the iDEW Trivia Library

You will come across bits of code that use the iDEW trivia library -- for example, `trivia.loadGoogleSheet( )` , `trivia.insertQuestionInfo( )`, `trivia.totalQuestions`. These methods and trivia values were designed to make programming your game easier. Once you dig in to your own game design you will want to review all the goodies offered in the Trivia Library Reference section of this book.

### Load Questions Then Display Welcome

**Update your `setup ( )` function to match the one below that loads the example question database.** You will eventually change the `googleSheetLink` value to your own. Notice that once the questions are loaded (see `.then` in code) the `displayWelcome ( )` function is called.

{% code title="JS" %}

```javascript
//Runs once at the beginning
function setup() {
  var googleSheetLink = "https://docs.google.com/spreadsheets/d/e/2PACX-1vRYCi4KENeZMlf9JbV8BhVrdOHse2250INSiRo7gEYWUYp3V0jiWFKWcnm1jzx5q1BMsmd9fOopk2Z_/pub?output=csv";
  trivia.loadGoogleSheet(googleSheetLink).then(displayWelcome); 
}
```

{% endcode %}

{% hint style="info" %}
**Note:** The updated Google Sheet Link (as of August 30, 2021) used above works with the latest Trivia Library release (1.2.0 +).
{% endhint %}

**Update your displayWelcome( ) function to match the one below.** This function first hides all screens, since they are all of class "screen". Then, only the *welcome-screen* is displayed using it's unique *id*.

{% code title="JS" %}

```javascript
function displayWelcome() {
  $(".screen").hide();
  $("#welcome-screen").show();
}
```

{% endcode %}

### Responding to Start Button Click

The `onClickedStart( )` function is called by the Trivia library when a button of class "start" is clicked, like the one in your welcome screen HTML and thank you screen HTML. Here we simply call the `displayQuestion( )` function. You may add more code here later for additional game features.

**Update your `onClickedStart( )` function as below.**

{% code title="JS" %}

```javascript
function onClickedStart() {
  displayQuestion();
}
```

{% endcode %}

Below the `displayQuestion( )` function hides all HTML screen then displays only the question screen. Then the question info (category, question, and answers) are inserted into the question screen HTML using a method from the Trivia library. The answers are then shuffled for obvious reasons. Update your `displayQuestion( )` function to match.

**Update your `displayQuestion( )` function as below.**

{% code title="JS" %}

```javascript
function displayQuestion() {
  $(".screen").hide();
  $("#question-screen").show();
  trivia.insertQuestionInfo();
  trivia.shuffleAnswers();
}
```

{% endcode %}

Test your code. Your game will get stuck at the first question, but we will address that next.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.launchboard.app/cxd/code-trivia-app-1/code-template/template-build-tutorial/6.-load-questions-and-go.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
