O'Reilly logo

Alexa Skills Projects by Madhur Bhargava

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Coding the Lambda function

We will be editing the code inline, in the index.js file in the developer portal itself:

  1. First of all, we shall define an array of JSON, which will contain the quiz questions to be posed by the trivia skill. This can be defined right at the top of the index.js file, even before the exports.handler:

//questions is an array of json objectsvar questions = [    {        "World War I began in which year?": [            "1923",            "1938",            "1917",            "1914"        ]    },    {        "Adolf Hitler was born in which country?": [            "France",            "Austria",            "Hungary",            "Germany"        ]    },    {        "The battle of Hastings was fought in which country?": [            "France",            "Russia",            "England",            "Norway"        ]    }];var correctAnswerSlots = [3, 1, 2];

As shown in the preceding code, apart from the questions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required