누군가가 나를 도울 수 있기를 바랍니다. 나는 다 언어 Alexa 기술을 창조하는 것을 시도한다.2 차원 배열에서 임의의 값 검색
는 다음과 같이 알렉사에서 샘플 코드에서 제공처럼 내 주요 파일의 언어 상수가 있습니다
const languageString = {
'en': {
'translation': {
'QUESTIONS': questions['QUESTIONS_EN_US'],
'GAME_NAME': 'My Quiz', // Be sure to change this for your skill.
'HELP_MESSAGE': 'I will ask you %s multiple choice questions. Respond with the number of the answer. ' +
'For example, say one, two, three, or four. To start a new game at any time, say, start game. ',
모든 것이 잘 작동하고 그래서 게임이되도록, 지금 몇 가지 다른 문자열을 추가하고 싶었 덜 지루한. 그래서 나는 correct.js 파일을 생성하고이 같은 내 문서에 정의 :이 파일은 다음과 같습니다
const correct = require('./correct');
:
'use strict';
module.exports = {
CORRECT_EN_GB: [
"Booya", "All righty", "Bam", "Bazinga", "Bingo", "Boom", "Bravo", "Cha Ching", "Cheers", "Dynomite",
"Hip hip hooray", "Hurrah", "Hurray", "Huzzah", "Oh dear. Just kidding. Hurray", "Kaboom", "Kaching", "Oh snap", "Phew",
"Righto", "Way to go", "Well done", "Whee", "Woo hoo", "Yay", "Wowza", "Yowsa"
],
CORRECT_EN_US: [
"Booya", "All righty", "Bam", "Bazinga", "Bingo", "Boom", "Bravo", "Cha Ching", "Cheers", "Dynomite",
"Hip hip hooray", "Hurrah", "Hurray", "Huzzah", "Oh dear. Just kidding. Hurray", "Kaboom", "Kaching", "Oh snap", "Phew",
"Righto", "Way to go", "Well done", "Whee", "Woo hoo", "Yay", "Wowza", "Yowsa"
],
CORRECT_DE_DE: [
"Aber hallo", "Bazinga", "Bingo", "Bravo", "Donnerwetter",
"en garde", "hipp hipp hurra", "hurra", "japp", "jawohl", "jo", "juhu", "na sieh mal einer an", "Stimmt",
"Super", "Supi", "tada", "türlich", "yay"
],
};
지금 내가 내 목록의 임의의 값을 검색 할 내 언어 문자열이 코드를 시도 :
'ANSWER_CORRECT_MESSAGE': '<say-as interpret-as="interjection">' + correct['CORRECT_EN_US'][Math.floor(Math.random() * correct['CORRECT_EN_US'].length)] + '</say-as><break time="1s"/> your reply is correct.<break time="2s"/>',
을하지만 내가 (다차원?) 배열 중 임의의 값을 검색하는 방법을 모른다 정직하게, 작동하지 않습니다.
누구나 나를 올바른 코드로 안내 할 수 있습니까? 고맙습니다!
엘리사
[다차원 배열에서 임의의 번호 가져 오기] (https://stackoverflow.com/questions/25010032/get-random-number-from-multidimensional-array) – Tomm
의 가능한 복제본 표시된 정답을 살펴보십시오. https : //stackoverflow.com/questions/25010032/get-random-number-from-multidimensional-array – Tomm