CARVIEW |
Select Language
HTTP/2 200
content-type: text/html
x-guploader-uploadid: AAwnv3LwxgvzysIpcfTwRFaVoyjy3XsH_noalbly4XjUhUfz2jklthxxTcPqemRwXusbvmxH
cache-control: public, max-age=3600
expires: Fri, 10 Oct 2025 08:25:19 GMT
last-modified: Fri, 10 Oct 2025 01:10:22 GMT
etag: W/"3163322db8401b9965bf2775ae2a5414"
x-goog-generation: 1760058622408935
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 192946
x-goog-meta-goog-reserved-file-mtime: 1760057027
x-goog-hash: crc32c=SkYjOQ==, md5=MWMyLbhAG5llvyd1ripUFA==
x-goog-storage-class: STANDARD
accept-ranges: none
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
alt-svc: clear
referrer-policy: strict-origin-when-cross-origin
x-content-type-options: nosniff
strict-transport-security: max-age=63072000
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net mdn.github.io live-samples.mdn.mozilla.net live-samples.mdn.allizom.net *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-frame-options: DENY
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
x-cloud-trace-context: f394b426e8a73006d1d77e0502dcd77b
date: Fri, 10 Oct 2025 07:25:19 GMT
server: Google Frontend
via: 1.1 google
vary: Accept-Encoding
content-encoding: gzip
x-cache: miss
スキルテスト: 配列 - ウェブ開発の学習 | MDN
Toggle sidebar
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
スキルテスト: 配列
このスキルテストの目的は、配列の記事を理解しているかどうかを評価することです。
メモ: 手助けが必要な場合は、スキルテスト使用ガイドをお読みください。また、コミュニケーションチャネルのいずれかを使用して、私たちに連絡することもできます。
メモ: この課題は、このコースではまだ明示的に扱っていない JavaScript の機能に頼っているため、やや難しい目標です。最善を尽くして、わからないことはオンラインで情報を探してください。
配列 1
この課題では、配列の基本的な練習をします。
- 3 つのアイテムの配列を作成し、それを
myArray
という変数に格納します。アイテムは、お好きなものなら何でもかまいません。好きな食べ物やバンド名などはどうでしょうか。 - 次に、ブラケット記法と代入を使用して、配列の最初の 2 つのアイテムを変更します。
- 最後に、配列の先頭に新しいアイテムを追加します。
<section></section>
* {
box-sizing: border-box;
}
p {
color: purple;
margin: 0.5em 0;
}
js
// ここにコードを追加
// 以下のコードは編集しないでください。
const section = document.querySelector("section");
const para1 = document.createElement("p");
para1.textContent = `Array: ${myArray}`;
section.appendChild(para1);
ここをクリックすると、模範解答を表示します。
完成した JavaScript は、次のようになるでしょう。
js
const myArray = ["cats", "dogs", "chickens"];
myArray[0] = "horses";
myArray[1] = "pigs";
myArray.unshift("crocodiles");
// 以下のコードは編集しないでください。
// ...
配列 2
さて、別の課題に移りましょう。ここでは、取り組むべき文字列が与えられています。
この課題を完成させるには、次のようにします。
- 文字列を配列に変換してください。その過程で、
+
という文字を取り除きます。結果をmyArray
という変数に格納しましょう - 配列の要素数を、
arrayLength
という変数に格納しましょう。 - 配列の末尾の要素を、
lastItem
という変数に格納しましょう。
js
const myString = "Ryu+Ken+Chun-Li+Cammy+Guile+Sakura+Sagat+Juri";
// ここにコードを追加
// 以下のコードは編集しないでください。
const section = document.querySelector("section");
const para1 = document.createElement("p");
para1.textContent = `Array: ${myArray}`;
const para2 = document.createElement("p");
para2.textContent = `The length of the array is ${arrayLength}.`;
const para3 = document.createElement("p");
para3.textContent = `The last item in the array is "${lastItem}".`;
section.appendChild(para1);
section.appendChild(para2);
section.appendChild(para3);
ここをクリックすると、模範解答を表示します。
完成した JavaScript は、次のようになるでしょう。
js
const myString = "Ryu+Ken+Chun-Li+Cammy+Guile+Sakura+Sagat+Juri";
let myArray = myString.split("+");
let arrayLength = myArray.length;
let lastItem = myArray[arrayLength - 1];
// 以下のコードは編集しないでください。
// ...
配列 3
このタスクでは、用意した配列を出発点として、やや逆行する作業を行います。具体的には、
- 配列の末尾の要素を削除しましょう。
- 配列の末尾に新たに 2 つの名前を追加しましょう。
- 配列の各要素を調べて、要素のインデックス番号を丸括弧で囲み、名前の後ろに追記しましょう。例:
Ryu (0)
。 なお、このやり方は配列の記事では教えていませんので、自分で調べる必要があるでしょう。 - 最後に、配列の各要素を
"-"
で区切って 1 つの文字列に結合し、myString
という変数に格納しましょう。
js
const myArray = [
"Ryu",
"Ken",
"Chun-Li",
"Cammy",
"Guile",
"Sakura",
"Sagat",
"Juri",
];
// ここにコードを追加
// 以下のコードは編集しないでください。
const section = document.querySelector("section");
const para1 = document.createElement("p");
para1.textContent = myString;
section.appendChild(para1);
ここをクリックすると、模範解答を表示します。
完成した JavaScript は、次のようになるでしょう。
js
const myArray = [
"Ryu",
"Ken",
"Chun-Li",
"Cammy",
"Guile",
"Sakura",
"Sagat",
"Juri",
];
myArray.pop();
myArray.push("Zangief");
myArray.push("Ibuki");
myArray.forEach((element, index) => {
const newElement = `${element} (${index})`;
myArray[index] = newElement;
});
const myString = myArray.join(" - ");
// 以下のコードは編集しないでください。
// ...
配列 4
この配列の課題では、いくつかの鳥の名前を記載した配列を提供しています。
この課題を完成させるには、次のようにします。
"Eagles"
要素のインデックスを特定し、そのインデックスを用いて"Eagles"
要素を削除しましょう。- この配列から、名前が "E" で始まる鳥だけを含む
eBirds
という名前の新しい配列を作成しましょう。ちなみに、startsWith()
は文字列が特定の文字で始まるかどうかを調べるのにとても役立ちます。
"Emus,Egrets"
と表示されたら成功です。
js
const birds = ["Parrots", "Falcons", "Eagles", "Emus", "Caracaras", "Egrets"];
// ここにコードを追加
// 以下のコードは編集しないでください。
const section = document.querySelector("section");
const para1 = document.createElement("p");
para1.textContent = eBirds;
section.appendChild(para1);
ここをクリックすると、模範解答を表示します。
完成した JavaScript は、次のようになるでしょう。
js
const birds = ["Parrots", "Falcons", "Eagles", "Emus", "Caracaras", "Egrets"];
const eaglesIndex = birds.indexOf("Eagles");
birds.splice(eaglesIndex, 1);
function startsWithE(bird) {
return bird.startsWith("E");
}
const eBirds = birds.filter(startsWithE);
// 以下のコードは編集しないでください。
// ...