如何访问 code.org 中数据集包含超过 10k 个值的列表中的元素
所以我尝试使用 wordle 数据集在 code.org 内重新创建一个 wordle 游戏。
//Getting Wordle Answer
var answers = getColumn("Wordle", "validWordleAnswer");
var letters = ["letter1", "letter2", "letter3", "letter4", "letter5"];
var index = (randomNumber(0, answers.length));
console.log(index);
因此,console.log 当然会输出我的索引号,但是在数据集中存储的 10k 个单词中,我如何访问随机数生成的特定单词?例如,索引为 500,我可以写什么才能在 console.log 中得到正确的答案?谢谢?
so I am trying to recreate a wordle game inside of code.org using the wordle dataset.
//Getting Wordle Answer
var answers = getColumn("Wordle", "validWordleAnswer");
var letters = ["letter1", "letter2", "letter3", "letter4", "letter5"];
var index = (randomNumber(0, answers.length));
console.log(index);
So ofcourse the console.log outputs my index number, but out of the 10k words that are stored in the dataset, how can I access the specific one that the randomnumber generated? Foe example the index was 500, what can I write inorder to console.log the correct answer? Thanks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数组的长度并不重要,1 个元素或 200 亿。您仍然可以使用方括号表示法来访问它:
这是一个小示例(请记住,索引从 0 开始):
The length of the array doesn't matter, 1 element or 20 billion. You still access it with bracket notation:
Here's a small example (remember, indexing starts at 0):