Javascript 管理代码中大量硬编码数据的最佳方法?

Javascript 管理代码中大量硬编码数据的最佳方法?,javascript,data-structures,model,refactoring,Javascript,Data Structures,Model,Refactoring,我正在使用Javascript进行在线测试。我将通道库组织为一个数组,正如您所看到的,它非常混乱(很抱歉代码墙): var passageBank=[ [“第1段”,//段落标题 1960年,乔治·斯珀林博士要求参与者回忆屏幕上闪烁不到一秒钟的一组4x3字母。当被要求回忆尽可能多的字母时,大多数参与者只能说出前四五个字母。斯珀林博士然后要求另一组只说出其中一行。在他们看到图像后闪光时,他会随机发出三个音调中的一个。发出高频音调表示参与者应该给出第一行字母;中频音调表示中间一行;低频音调表示最后一

我正在使用Javascript进行在线测试。我将通道库组织为一个数组,正如您所看到的,它非常混乱(很抱歉代码墙):

var passageBank=[
[“第1段”,//段落标题
1960年,乔治·斯珀林博士要求参与者回忆屏幕上闪烁不到一秒钟的一组4x3字母。当被要求回忆尽可能多的字母时,大多数参与者只能说出前四五个字母。斯珀林博士然后要求另一组只说出其中一行。在他们看到图像后闪光时,他会随机发出三个音调中的一个。发出高频音调表示参与者应该给出第一行字母;中频音调表示中间一行;低频音调表示最后一行。如果在图像闪光后立即播放该音调,大多数受试者会回忆起这标志着标志性记忆的发现,即感官记忆的视觉形式。听觉感官记忆(也称为回声记忆)持续几秒钟。

图1斯珀林博士的实验设置感官记忆不断处理来自你周围世界的大量信息。你所关注的内容会传递到工作记忆中。这一阶段可以分为三个主要部分——视觉空间画板、音系循环和记忆中央执行官。画板存储视觉信息,如照片,而循环处理文字和数字。协调两者的工作落在中央执行官身上——例如,将你听到的地址与你看到的地图连接起来。

,//带格式的段落 [/*一系列问题*/ /*问题1*/ “Sterling博士为什么用音调表示他希望参与者背诵的那一行?”, /*A*/ “口头提问所需时间将超过标志性记忆的持续时间”, /*B*/ “斯珀林博士打算研究声音和视觉线索之间的联系”, /*C*/ “这是向多个参与者发出问题信号的最清晰方式”, /*D*/ “使用声音提示有助于触发回声记忆”, /*答复*/ “A”, /*学生回答*/ “X”, /*解决方案*/ “这些音调是第二轮实验的一部分。

人们认为标志性记忆只持续了几分之一秒。

为了测试标志性记忆,斯珀林博士需要一种足够快的刺激,使图像仍然在参与者的头脑中。” ], [/*问题2*/“哪一个是回声记忆的最佳测试?”,“要求参与者提供一首著名歌曲的下一行”,“要求参与者总结一个故事,并向他们宣读”,“要求参与者确定两个音调是否相同”,“要求参与者唱他们最喜欢的歌曲的第一行”,“C”,“X”,“回声记忆是感官记忆的一种形式,它的寿命很短。

回声记忆是我们不断从外部世界处理的信息的一个可听片段。

要求参与者识别两个音调是否相同是回声记忆的最佳测试。”, [/*问题3*/“以下哪项解释了为什么我们在翻页簿或定格动画中看到运动?”、“标志性记忆”、“中央执行”、“回声记忆”、“视觉空间画板”、“a”、“X”翻页书和定格动画都是在眼睛前面快速连续闪现的一系列静止图像,以创建运动图像。

中央执行官负责协调视觉空间画板和语音循环。

图标记忆是变化检测的主要部分,帮助我们注意变化在每个逐行扫描图像中,将其转换为单个运动图像。“], [/*问题4*/“如果你开车经过一个停车标志,几分钟后试图回忆它,你使用的是哪一种?”,“回声记忆,然后是语音回路”,“回声记忆,然后是视觉空间画板”,“标志性记忆,然后是视觉空间画板”,“标志性记忆,然后是语音回路”,“D”,“X”信息通过感官记忆传递到工作记忆。

停止符号是一个单词的图片。

停止符号(一个单词的图片)将首先通过标志性记忆,然后进入语音循环。“”, [/*问题5*/“以下哪一项是用于增加工作记忆中存储信息量的技术?”,“语义网络”、“图像”、“自我参照”、“分块”、“D”、“X”许多记忆技术都专注于将信息从工作记忆转移到长期记忆。

语义网络就像我们头脑中的思维地图,我们在其中连接相关概念。

分块是将信息分组以减少“基准”数目的过程存储,以便在工作内存中存储更多的信息。例如:将TVfBihPCB记住为电视FBI HP CBS。“]], ]]
它是有效的,但在上下文中引用和理解它很烦人。我哥哥明智地指出,它可能会更好地以类似字典的格式组织。(对于所有学究来说——显然javascript实际上没有字典?但不管它是什么,似乎都足够接近了)

我试过这样做:

var passageBank = {
        'Passage 1': '<p>In 1960, Dr. George Sperling asked participants to recall a 4x3 group of letters flashed on a screen for less than a second. When instructed to recall as many letters as possible, most participants could only name the first four or five letters.</p><p>Dr. Sperling then asked another group to name only one of the rows. After they saw the image flash, he would randomly sound one of three tones. Sounding a high-frequency tone indicated that the participant should give the first line of letters; a medium-frequency tone indicated the middle row; and a low-frequency tone asked for the last row. If the tone was broadcast immediately after the image was flashed, the majority of subjects recalled all four letters. This marked the discovery of iconic memory, the visual form of sensory memory. Audible sensory memory (also known as echoic memory) lasts for several seconds.</p><div id="figure"><img src="https://ka-perseus-images.s3.amazonaws.com/a7d4238a28e6eef5321d3f6278fb17ce5a9461cf.png"></div><b>Figure 1</b><span id="figure">Experimental setup for Dr. Sperling</span><p>Sensory memory is constantly processing enormous amounts of information from the world around you. What you pay attention to gets passed into working memory. This stage can be described in three major sections – the visuospatial sketchpad, the phonological loop, and the central executive. The sketchpad stores visual information, like a photograph, while the loop deals with words and numbers. The job of coordinating the two falls to the central executive – connecting an address you hear with a map that you see, for example.</p>', //Passage with Formatting
    }
var passageBank={
“第1段”:“1960年,乔治·斯珀林博士要求参与者回忆屏幕上闪烁不到一秒钟的一组4x3字母。当被要求回忆尽可能多的字母时,大多数参与者只能说出前4或5个字母。

斯珀林博士然后要求另一组只说出其中一行。在他们回答完后当图像闪烁时,他会随机发出三种音调中的一种。发出一种高频音调表示
var passageBank = {
        'Passage 1': '<p>In 1960, Dr. George Sperling asked participants to recall a 4x3 group of letters flashed on a screen for less than a second. When instructed to recall as many letters as possible, most participants could only name the first four or five letters.</p><p>Dr. Sperling then asked another group to name only one of the rows. After they saw the image flash, he would randomly sound one of three tones. Sounding a high-frequency tone indicated that the participant should give the first line of letters; a medium-frequency tone indicated the middle row; and a low-frequency tone asked for the last row. If the tone was broadcast immediately after the image was flashed, the majority of subjects recalled all four letters. This marked the discovery of iconic memory, the visual form of sensory memory. Audible sensory memory (also known as echoic memory) lasts for several seconds.</p><div id="figure"><img src="https://ka-perseus-images.s3.amazonaws.com/a7d4238a28e6eef5321d3f6278fb17ce5a9461cf.png"></div><b>Figure 1</b><span id="figure">Experimental setup for Dr. Sperling</span><p>Sensory memory is constantly processing enormous amounts of information from the world around you. What you pay attention to gets passed into working memory. This stage can be described in three major sections – the visuospatial sketchpad, the phonological loop, and the central executive. The sketchpad stores visual information, like a photograph, while the loop deals with words and numbers. The job of coordinating the two falls to the central executive – connecting an address you hear with a map that you see, for example.</p>', //Passage with Formatting
    }
allQuestions = []

function question(options, answer, solution, title) {
this.title = title;
this.options = options;
this.answer = answer;
this.solution = solution;
allQuestions.push(this)
}
new question(options, answer, solution, title);
allQuestions[0].title
[
    {
        "title": "Passage 1",
        "text": "…",
        "questions": [
            {
                "label": "…",
                "choices": ["…"],
                "answer": "…",
                "solution": "…"
            },
            { ... },
            { ... }
        ]
    },
    {
        "title": "Passage 2",
        ...
    },
    {
        "title": "Passage 3",
        ...
    }
]