freeCodeCamp/curriculum/challenges/chinese-traditional/02-javascript-algorithms-an.../basic-javascript/store-multiple-values-in-on...

1.2 KiB

id title challengeType videoUrl forumTopicId dashedName
bd7993c9c69feddfaeb8bdef 使用 JavaScript 數組將多個值存儲在一個變量中 1 https://scrimba.com/c/crZQWAm 18309 store-multiple-values-in-one-variable-using-javascript-arrays

--description--

使用數組(array),我們可以在一個地方存儲多個數據。

以左方括號開始定義一個數組,以右方括號結束,裏面每個元素之間用逗號隔開,例如:

const sandwich = ["peanut butter", "jelly", "bread"];

--instructions--

創建一個包含字符串和數字(按照字符串和數字的順序)的數組 myArray

--hints--

myArray 應爲數組。

assert(typeof myArray == 'object');

myArray 數組的第一個元素應該是一個字符串。

assert(typeof myArray[0] !== 'undefined' && typeof myArray[0] == 'string');

myArray 數組的第二個元素應該是一個數字。

assert(typeof myArray[1] !== 'undefined' && typeof myArray[1] == 'number');

--seed--

--after-user-code--

(function(z){return z;})(myArray);

--seed-contents--

// Only change code below this line
const myArray = [];

--solutions--

const myArray = ["The Answer", 42];