mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-11 16:00:12 -04:00
1.4 KiB
1.4 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56104e9e514f539506016a5c | For 루프로 홀수 순환하기 | 1 | https://scrimba.com/c/cm8n7T9 | 18212 | iterate-odd-numbers-with-a-for-loop |
--description--
For 루프는 한 번에 하나만 순환할 필요가 없습니다. final-expression 변경하여 짝수로 세어 나갈 수 있습니다.
i = 0에 시작하여 i < 10인 동안 루프를 순환할 것입니다. i += 2으로 매 순환하마다 2씩 i를 증가시킬 것입니다.
const ourArray = [];
for (let i = 0; i < 10; i += 2) {
ourArray.push(i);
}
ourArray는 이제 [0, 2, 4, 6, 8]를 포함할 것입니다. initialization를 변경하여 홀수로 세어 나갈 수 있습니다.
--instructions--
for 루프로 myArray에 1부터 9 중 홀수를 추가하시오.
--hints--
이를 위해 for 루프를 사용해야 합니다.
assert(/for\s*\([^)]+?\)/.test(__helpers.removeJSComments(code)));
myArray는 [1, 3, 5, 7, 9]와 같아야 합니다.
assert.deepEqual(myArray, [1, 3, 5, 7, 9]);
--seed--
--after-user-code--
if(typeof myArray !== "undefined"){(function(){return myArray;})();}
--seed-contents--
// Setup
const myArray = [];
// Only change code below this line
--solutions--
const myArray = [];
for (let i = 1; i < 10; i += 2) {
myArray.push(i);
}