Learn

Like variables, session attributes hold values that we can change after we’ve created them.

For example, if any of our session attributes are numbers, we can set their initial values and use number operations (e.g. increment) to overwrite them later.

'LaunchRequest': function() { this.attributes['currentIndex'] = 0; };

The attributes field holds an object with a field named currentIndex set to the value 0.

In this lesson, you will keep track of the number of flashcards in the same way — each time a user answers one of the questions, we will increment the value saved to the currentIndex attribute as follows:

this.attributes['currentIndex']++;

Instructions

1.

Take a look at the conditional statement in the AnswerIntent. In the if statement, the user answer is correct. Increment the numberCorrect session attribute.

2.

In both the if and else statements, increment the currentFlashcardIndex session attribute by one.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?