Add languages Russian, Arabic, Chinese, Portuguese (#18305)
This commit is contained in:
committed by
mrugesh mohapatra
parent
09d3eca712
commit
2ca3a2093f
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392ca
|
||||
title: Access Array Data with Indexes
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert((function(){if(typeof myArray !== "undefined" && typeof myData !== "undefined" && myArray[0] === myData){return true;}else{return false;}})(), "The variable <code>myData</code> should equal the first value of <code>myArray</code>.");'
|
||||
- text: يجب الوصول إلى البيانات في متغير <code>myArray</code> باستخدام تدوين قوس.
|
||||
testString: 'assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})(), "The data in variable <code>myArray</code> should be accessed using bracket notation.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = [50,60,70];
|
||||
var ourData = ourArray[0]; // equals 50
|
||||
|
||||
// Setup
|
||||
var myArray = [50,60,70];
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: 56592a60ddddeae28f7aa8e1
|
||||
title: Access Multi-Dimensional Arrays With Indexes
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
|
||||
videoUrl: ''
|
||||
localeTitle: الوصول إلى صفائف متعددة الأبعاد مع فهارس
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> طريقة واحدة للتفكير في مصفوفة <dfn>متعددة الأبعاد</dfn> ، هي بمثابة <em>صفيف من المصفوفات</em> . عند استخدام الأقواس للوصول إلى الصفيف الخاص بك ، تشير المجموعة الأولى من الأقواس إلى الإدخالات الموجودة في مصفوفة الجزء الخارجي (المستوى الأول) ، ويشير كل زوج إضافي من الأقواس إلى المستوى التالي من الإدخالات بالداخل. <strong>مثال</strong> <blockquote style=";text-align:right;direction:rtl"> var arr = [ <br> [1،2،3]، <br> [4،5،6]، <br> [7،8،9]، <br> [[10،11،12] ، 13 ، 14] <br> ]. <br> آر [3]. // يساوي [[10،11،12] ، 13 ، 14] <br> آر [3] [0]؛ // يساوي [10،11،12] <br> آر [3] [0] [1]؛ // يساوي 11 </blockquote> <strong>ملحوظة</strong> <br> يجب ألا يكون هناك أي مسافات بين اسم الصفيف والأقواس المربعة ، مثل <code>array [0][0]</code> وحتى هذا <code>array [0] [0]</code> غير مسموح به. على الرغم من أن JavaScript قادر على معالجة هذا بشكل صحيح ، فقد يؤدي ذلك إلى إرباك المبرمجين الآخرين في قراءة التعليمات البرمجية. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> باستخدام <code>myArray</code> قوس حدد عنصر من <code>myArray</code> بحيث يكون <code>myData</code> يساوي <code>8</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تساوي <code>myData</code> <code>8</code> .
|
||||
testString: 'assert(myData === 8, "<code>myData</code> should be equal to <code>8</code>.");'
|
||||
- text: يجب أن تستخدم تدوين قوس لقراءة القيمة الصحيحة من <code>myArray</code> .
|
||||
testString: 'assert(/myArray\[2\]\[1\]/g.test(code) && !/myData\s*=\s*(?:.*[-+*/%]|\d)/g.test(code), "You should be using bracket notation to read the correct value from <code>myArray</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
|
||||
|
||||
// Only change code below this line.
|
||||
var myData = myArray[0][0];
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244cd
|
||||
title: Accessing Nested Arrays
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
|
||||
videoUrl: ''
|
||||
localeTitle: الوصول إلى صفائف متداخلة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> كما رأينا في الأمثلة السابقة ، يمكن أن تحتوي الكائنات على كل من الكائنات المتداخلة والصفائف المتداخلة. على غرار الوصول إلى الكائنات المتداخلة ، يمكن تقييد تدرج قوس Array للوصول إلى صفائف متداخلة. فيما يلي مثال لكيفية الوصول إلى صفيف متداخل: <blockquote style=";text-align:right;direction:rtl"> var ourPets = [ <br> { <br> animalType: "قطة" ، <br> الأسماء: [ <br> "Meowzer" <br> "رقيق"، <br> "كيت كات" <br> ] <br> }، <br> { <br> animalType: "dog" ، <br> الأسماء: [ <br> "بقعة"، <br> "العربة"، <br> "فرانكي" <br> ] <br> } <br> ]. <br> ourPets [0] .names [1]؛ // "رقيق" <br> ourPets [1] .names [0]؛ // "سبوت" </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استرجاع الشجرة الثانية من <code>myPlants</code> المتغير باستخدام <code>myPlants</code> نقطة الكائن <code>myPlants</code> مجموعة الصفيف. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>secondTree</code> ينبغي أن يساوي "الصنوبر"
|
||||
testString: 'assert(secondTree === "pine", "<code>secondTree</code> should equal "pine"");'
|
||||
- text: استخدم نقطة <code>myPlants</code> قوس للوصول إلى <code>myPlants</code>
|
||||
testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), "Use dot and bracket notation to access <code>myPlants</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var myPlants = [
|
||||
{
|
||||
type: "flowers",
|
||||
list: [
|
||||
"rose",
|
||||
"tulip",
|
||||
"dandelion"
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "trees",
|
||||
list: [
|
||||
"fir",
|
||||
"pine",
|
||||
"birch"
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
var secondTree = ""; // Change this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244cc
|
||||
title: Accessing Nested Objects
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/accessing-nested-objects-in-json'
|
||||
videoUrl: ''
|
||||
localeTitle: الوصول إلى الكائنات المتداخلة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكن الوصول إلى الخصائص الفرعية للكائنات عن طريق ربط صيغة النقطة أو القوس. هنا كائن متداخل: <blockquote style=";text-align:right;direction:rtl"> var ourStorage = { <br> "مكتب": { <br> "الدرج": "دباسة" <br> }، <br> "خزانة": { <br> "الدرج العلوي": { <br> "folder1": "ملف" ، <br> "folder2": "secrets" <br> }، <br> "درج سفلي": "الصودا" <br> } <br> }؛ <br> ourStorage.cabinet ["top drawer"]. // "أسرار" <br> ourStorage.desk.drawer. // "دباسة" </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بالوصول إلى كائن <code>myStorage</code> وقم بتعيين محتويات خاصية <code>glove box</code> إلى متغير <code>gloveBoxContents</code> . استخدام تدرج قوس للمواقع مع مساحة في أسمائهم. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يساوي <code>gloveBoxContents</code> "الخرائط"
|
||||
testString: 'assert(gloveBoxContents === "maps", "<code>gloveBoxContents</code> should equal "maps"");'
|
||||
- text: استخدم تدوين النقطة <code>myStorage</code> للوصول إلى <code>myStorage</code>
|
||||
testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|")glove box\1\s*\]/g.test(code), "Use dot and bracket notation to access <code>myStorage</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var myStorage = {
|
||||
"car": {
|
||||
"inside": {
|
||||
"glove box": "maps",
|
||||
"passenger seat": "crumbs"
|
||||
},
|
||||
"outside": {
|
||||
"trunk": "jack"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var gloveBoxContents = undefined; // Change this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c8
|
||||
title: Accessing Object Properties with Bracket Notation
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/accessing-objects-properties-with-bracket-notation'
|
||||
videoUrl: ''
|
||||
localeTitle: الوصول إلى خصائص كائن مع تدرج قوس
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> الطريقة الثانية للوصول إلى خصائص كائن تدوين قوس ( <code>[]</code> ). إذا كانت خاصية الكائن الذي تحاول الوصول إليه تحتوي على مسافة في اسمه ، فستحتاج إلى استخدام تدرج قوس. ومع ذلك ، لا يزال بإمكانك استخدام تدرج قوس على خصائص الكائن بدون مسافات. هنا عينة من استخدام تدرج قوس لقراءة خاصية الكائن: <blockquote style=";text-align:right;direction:rtl"> var myObj = { <br> "اسم الفضاء": "كيرك" ، <br> "مساحة إضافية": "سبوك" ، <br> "NoSpace": "USS Enterprise" <br> }؛ <br> myObj ["اسم الفضاء"] ؛ // كيرك <br> myObj ['More Space']؛ // سبوك <br> myObj [ "NoSpace"]؛ // يو اس اس انتربرايز </blockquote> لاحظ أن أسماء الخصائص التي تحتوي على مسافات يجب أن تكون بين علامتي اقتباس (مفرد أو مزدوج). </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قراءة قيم خصائص <code>"an entree"</code> و <code>"the drink"</code> من <code>testObj</code> باستخدام تدوين قوس <code>entreeValue</code> إلى <code>entreeValue</code> <code>drinkValue</code> على التوالي. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون <code>entreeValue</code> عبارة عن سلسلة
|
||||
testString: 'assert(typeof entreeValue === "string" , "<code>entreeValue</code> should be a string");'
|
||||
- text: يجب أن تكون قيمة <code>entreeValue</code> <code>"hamburger"</code>
|
||||
testString: 'assert(entreeValue === "hamburger" , "The value of <code>entreeValue</code> should be <code>"hamburger"</code>");'
|
||||
- text: يجب أن يكون <code>drinkValue</code> سلسلة
|
||||
testString: 'assert(typeof drinkValue === "string" , "<code>drinkValue</code> should be a string");'
|
||||
- text: قيمة <code>drinkValue</code> يجب أن تكون <code>"water"</code>
|
||||
testString: 'assert(drinkValue === "water" , "The value of <code>drinkValue</code> should be <code>"water"</code>");'
|
||||
- text: يجب عليك استخدام تدوين قوس مرتين
|
||||
testString: 'assert(code.match(/testObj\s*?\[("|")[^""]+\1\]/g).length > 1, "You should use bracket notation twice");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var testObj = {
|
||||
"an entree": "hamburger",
|
||||
"my side": "veggies",
|
||||
"the drink": "water"
|
||||
};
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
var entreeValue = testObj; // Change this line
|
||||
var drinkValue = testObj; // Change this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c7
|
||||
title: Accessing Object Properties with Dot Notation
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: الوصول إلى خصائص كائن مع ترميز Dot
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> هناك طريقتان للوصول إلى خصائص كائن: تدوين نقطي ( <code>.</code> ) وتدوين قوس ( <code>[]</code> ) ، شبيه بصفيف. Dot notation هو ما تستخدمه عندما تعرف اسم العقار الذي تحاول الوصول إليه في وقت مبكر. هنا عينة من استخدام تدوين النقطة ( <code>.</code> ) لقراءة خاصية الكائن: <blockquote style=";text-align:right;direction:rtl"> var myObj = { <br> prop1: "val1" ، <br> prop2: "val2" <br> }؛ <br> var prop1val = myObj.prop1 ، // val1 <br> var prop2val = myObj.prop2؛ // val2 </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قراءة في قيم خاصية <code>testObj</code> باستخدام التدوين النقطي. تعيين <code>hatValue</code> متغير يساوي <code>hat</code> خاصية الكائن وتعيين <code>shirtValue</code> متغير <code>shirtValue</code> يساوي <code>shirt</code> خاصية الكائن. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون <code>hatValue</code> سلسلة
|
||||
testString: 'assert(typeof hatValue === "string" , "<code>hatValue</code> should be a string");'
|
||||
- text: قيمة <code>hatValue</code> يجب أن تكون <code>"ballcap"</code>
|
||||
testString: 'assert(hatValue === "ballcap" , "The value of <code>hatValue</code> should be <code>"ballcap"</code>");'
|
||||
- text: يجب أن يكون <code>shirtValue</code> عبارة عن سلسلة
|
||||
testString: 'assert(typeof shirtValue === "string" , "<code>shirtValue</code> should be a string");'
|
||||
- text: يجب أن تكون قيمة <code>shirtValue</code> <code>"jersey"</code>
|
||||
testString: 'assert(shirtValue === "jersey" , "The value of <code>shirtValue</code> should be <code>"jersey"</code>");'
|
||||
- text: يجب عليك استخدام dot notation مرتين
|
||||
testString: 'assert(code.match(/testObj\.\w+/g).length > 1, "You should use dot notation twice");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var testObj = {
|
||||
"hat": "ballcap",
|
||||
"shirt": "jersey",
|
||||
"shoes": "cleats"
|
||||
};
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
var hatValue = testObj; // Change this line
|
||||
var shirtValue = testObj; // Change this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c9
|
||||
title: Accessing Object Properties with Variables
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/accessing-objects-properties-with-variables'
|
||||
videoUrl: ''
|
||||
localeTitle: الوصول إلى خصائص الكائن مع المتغيرات
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> استخدام آخر لتدوين قوس على الكائنات هو الوصول إلى خاصية يتم تخزينها كقيمة متغير. يمكن أن يكون هذا مفيدًا جدًا للتكرار من خلال خصائص الكائن أو عند الوصول إلى جدول البحث. في ما يلي مثال على استخدام متغير للوصول إلى موقع: <blockquote style=";text-align:right;direction:rtl"> var dogs = { <br> Fido: "Mutt"، Hunter: "Doberman"، Snoopie: "Beagle" <br> }؛ <br> var myDog = "Hunter" ؛ <br> var myBreed = dogs [myDog]؛ <br> console.log (myBreed)؛ // "دوبيرمان" </blockquote> هناك طريقة أخرى لاستخدام هذا المفهوم وهي عندما يتم جمع اسم المنشأة ديناميكيًا أثناء تنفيذ البرنامج ، كما يلي: <blockquote style=";text-align:right;direction:rtl"> var someObj = { <br> propName: "John" <br> }؛ <br> وظيفة propPrefix (str) { <br> var s = "prop" ؛ <br> return s + str؛ <br> } <br> var someProp = propPrefix ("Name")؛ // someProp الآن يحمل القيمة "propName" <br> console.log (someObj [someProp])؛ // "يوحنا" </blockquote> لاحظ أننا <em>لا</em> نستخدم علامات اقتباس حول اسم المتغير عند استخدامه للوصول إلى الخاصية لأننا نستخدم <em>قيمة</em> المتغير ، وليس <em>الاسم</em> . </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استخدم متغير <code>playerNumber</code> للبحث عن المشغل <code>16</code> في <code>testObj</code> باستخدام <code>testObj</code> قوس. ثم قم بتعيين هذا الاسم إلى متغير <code>player</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون <code>playerNumber</code> رقمًا
|
||||
testString: 'assert(typeof playerNumber === "number", "<code>playerNumber</code> should be a number");'
|
||||
- text: يجب أن يكون <code>player</code> المتغير عبارة عن سلسلة
|
||||
testString: 'assert(typeof player === "string", "The variable <code>player</code> should be a string");'
|
||||
- text: يجب أن تكون قيمة <code>player</code> "مونتانا"
|
||||
testString: 'assert(player === "Montana", "The value of <code>player</code> should be "Montana"");'
|
||||
- text: يجب عليك استخدام تدوين قوس للوصول إلى <code>testObj</code>
|
||||
testString: 'assert(/testObj\s*?\[.*?\]/.test(code),"You should use bracket notation to access <code>testObj</code>");'
|
||||
- text: يجب عدم تعيين قيمة <code>Montana</code> إلى <code>player</code> المتغير مباشرةً.
|
||||
testString: 'assert(!code.match(/player\s*=\s*"|\"\s*Montana\s*"|\"\s*;/gi),"You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.");'
|
||||
- text: يجب أن تستخدم المتغير <code>playerNumber</code> في تدوين <code>playerNumber</code>
|
||||
testString: 'assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code),"You should be using the variable <code>playerNumber</code> in your bracket notation");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var testObj = {
|
||||
12: "Namath",
|
||||
16: "Montana",
|
||||
19: "Unitas"
|
||||
};
|
||||
|
||||
// Only change code below this line;
|
||||
|
||||
var playerNumber; // Change this Line
|
||||
var player = testObj; // Change this Line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392d2
|
||||
title: Add New Properties to a JavaScript Object
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: أضف خصائص جديدة إلى كائن JavaScript
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكنك إضافة خصائص جديدة إلى كائنات JavaScript الموجودة بالطريقة نفسها التي يمكنك تعديلها بها. في ما يلي كيفية إضافة خاصية <code>"bark"</code> إلى <code>ourDog</code> : <code>ourDog.bark = "bow-wow";</code> أو <code>ourDog["bark"] = "bow-wow";</code> الآن عندما نقيم <code>ourDog.bark</code> ، <code>ourDog.bark</code> ، "bow-wow". </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة خاصية <code>"bark"</code> إلى <code>myDog</code> وتعيينه إلى صوت كلب ، مثل "woof". يمكنك استخدام أي نقطة أو تدوين قوس. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: إضافة <code>"bark"</code> الملكية إلى <code>myDog</code> .
|
||||
testString: 'assert(myDog.bark !== undefined, "Add the property <code>"bark"</code> to <code>myDog</code>.");'
|
||||
- text: لا تضف <code>"bark"</code> إلى قسم الإعداد
|
||||
testString: 'assert(!/bark[^\n]:/.test(code), "Do not add <code>"bark"</code> to the setup section");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourDog = {
|
||||
"name": "Camper",
|
||||
"legs": 4,
|
||||
"tails": 1,
|
||||
"friends": ["everything!"]
|
||||
};
|
||||
|
||||
ourDog.bark = "bow-wow";
|
||||
|
||||
// Setup
|
||||
var myDog = {
|
||||
"name": "Happy Coder",
|
||||
"legs": 4,
|
||||
"tails": 1,
|
||||
"friends": ["freeCodeCamp Campers"]
|
||||
};
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,59 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb3bdef
|
||||
title: Add Two Numbers with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: أضف رقمين مع JavaScript
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> <code>Number</code> هو نوع البيانات في JavaScript والذي يمثل البيانات الرقمية. الآن دعنا نحاول إضافة رقمين باستخدام JavaScript. تستخدم JavaScript الرمز <code>+</code> كعملية إضافة عند وضعها بين رقمين. <strong>مثال</strong> <blockquote style=";text-align:right;direction:rtl"> myVar = 5 + 10؛ // المعين 15 </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> تغيير <code>0</code> بحيث يساوي مجموع <code>20</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>sum</code> يجب أن يساوي <code>20</code>
|
||||
testString: 'assert(sum === 20, "<code>sum</code> should equal <code>20</code>");'
|
||||
- text: استخدم عامل التشغيل <code>+</code>
|
||||
testString: 'assert(/\+/.test(code), "Use the <code>+</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var sum = 10 + 0;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244de
|
||||
title: Adding a Default Option in Switch Statements
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/adding-a-default-option-in-switch-statements'
|
||||
videoUrl: ''
|
||||
localeTitle: إضافة خيار افتراضي في تبديل البيانات
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في بيان <code>switch</code> قد لا تتمكن من تحديد جميع القيم المحتملة كبيانات <code>case</code> . بدلاً من ذلك ، يمكنك إضافة العبارة <code>default</code> التي سيتم تنفيذها في حالة عدم العثور على عبارات <code>case</code> مطابقة. أعتقد أنه من مثل النهائي <code>else</code> بيان في <code>if/else</code> السلسلة. يجب أن تكون العبارة <code>default</code> هي الحالة الأخيرة. <blockquote style=";text-align:right;direction:rtl"> التبديل (عدد) { <br> قيمة الحالة 1: <br> statement1. <br> استراحة؛ <br> قيمة الحالة 2: <br> statement2. <br> استراحة؛ <br> ... <br> الافتراضي: <br> defaultStatement. <br> استراحة؛ <br> } </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> اكتب عبارة تبديل لتعيين <code>answer</code> عن الشروط التالية: <br> <code>"a"</code> - "apple" <br> <code>"b"</code> - "طائر" <br> <code>"c"</code> - "cat" <br> <code>default</code> - "الاشياء" </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون لـ <code>switchOfStuff("a")</code> قيمة "apple"
|
||||
testString: 'assert(switchOfStuff("a") === "apple", "<code>switchOfStuff("a")</code> should have a value of "apple"");'
|
||||
- text: يجب أن يكون <code>switchOfStuff("b")</code> قيمة "bird"
|
||||
testString: 'assert(switchOfStuff("b") === "bird", "<code>switchOfStuff("b")</code> should have a value of "bird"");'
|
||||
- text: يجب أن يكون لـ <code>switchOfStuff("c")</code> قيمة "cat"
|
||||
testString: 'assert(switchOfStuff("c") === "cat", "<code>switchOfStuff("c")</code> should have a value of "cat"");'
|
||||
- text: يجب أن يكون لـ <code>switchOfStuff("d")</code> قيمة "الأشياء"
|
||||
testString: 'assert(switchOfStuff("d") === "stuff", "<code>switchOfStuff("d")</code> should have a value of "stuff"");'
|
||||
- text: يجب أن يكون <code>switchOfStuff(4)</code> قيمة "الأشياء"
|
||||
testString: 'assert(switchOfStuff(4) === "stuff", "<code>switchOfStuff(4)</code> should have a value of "stuff"");'
|
||||
- text: يجب عدم استخدام أي <code>if</code> أو <code>else</code> البيانات
|
||||
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
- text: يجب عليك استخدام العبارة <code>default</code>
|
||||
testString: 'assert(switchOfStuff("string-to-trigger-default-case") === "stuff", "You should use a <code>default</code> statement");'
|
||||
- text: يجب أن يكون لديك على الأقل 3 بيانات <code>break</code>
|
||||
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function switchOfStuff(val) {
|
||||
var answer = "";
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return answer;
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
switchOfStuff(1);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ed
|
||||
title: Appending Variables to Strings
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/appending-variables-to-strings'
|
||||
videoUrl: ''
|
||||
localeTitle: إلحاق المتغيرات بالسلاسل
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> مثلما يمكننا بناء سلسلة على عدة أسطر من <dfn>القيم الحرفية</dfn> ، يمكننا أيضًا إضافة متغيرات إلى سلسلة باستخدام عامل plus equals ( <code>+=</code> ). </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> <code>someAdjective</code> إلى <code>myStr</code> باستخدام <code>+=</code> عامل التشغيل. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>someAdjective</code> يجب تعيين إلى سلسلة 3 أحرف على الأقل طويلة
|
||||
testString: 'assert(typeof someAdjective !== "undefined" && someAdjective.length > 2, "<code>someAdjective</code> should be set to a string at least 3 characters long");'
|
||||
- text: إلحاق <code>someAdjective</code> إلى <code>myStr</code> باستخدام <code>+=</code> عامل التشغيل
|
||||
testString: 'assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0, "Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var anAdjective = "awesome!";
|
||||
var ourStr = "freeCodeCamp is ";
|
||||
ourStr += anAdjective;
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
var someAdjective;
|
||||
var myStr = "Learning to code is ";
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c3
|
||||
title: Assignment with a Returned Value
|
||||
challengeType: 1
|
||||
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/assignment-with-a-returned-value'
|
||||
videoUrl: ''
|
||||
localeTitle: التنازل مع القيمة المرتجعة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> إذا كنت ستتذكر من مناقشتنا لـ <a href="javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank">Storing Values مع Assignment Operator</a> ، يتم حل كل شيء على يمين علامة المساواة قبل تعيين القيمة. هذا يعني أنه يمكننا أخذ قيمة الإرجاع للدالة وتعيينها لمتغير. افترض أننا حددنا مسبقا <code>sum</code> وظيفة يضيف رقمين معا ، ثم: <code>ourSum = sum(5, 12);</code> سوف تستدعي دالة <code>sum</code> ، والتي تُرجع قيمة <code>17</code> <code>ourSum</code> المتغير. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استدعاء الدالة <code>processArg</code> مع وسيطة من <code>7</code> وتعيين قيمته الإرجاع إلى المتغير <code>processed</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>processed</code> يجب أن يكون لها قيمة <code>2</code>
|
||||
testString: 'assert(processed === 2, "<code>processed</code> should have a value of <code>2</code>");'
|
||||
- text: يجب عليك تعيين <code>processArg</code> <code>processed</code>
|
||||
testString: 'assert(/processed\s*=\s*processArg\(\s*7\s*\)\s*;/.test(code), "You should assign <code>processArg</code> to <code>processed</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var changed = 0;
|
||||
|
||||
function change(num) {
|
||||
return (num + 5) / 3;
|
||||
}
|
||||
|
||||
changed = change(10);
|
||||
|
||||
// Setup
|
||||
var processed = 0;
|
||||
|
||||
function processArg(num) {
|
||||
return (num + 3) / 5;
|
||||
}
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392d0
|
||||
title: Build JavaScript Objects
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: بناء كائنات جافا سكريبت
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> ربما سمعت المصطلح <code>object</code> قبل. تشبه الكائنات <code>arrays</code> ، إلا أنه بدلاً من استخدام الفهارس للوصول إلى بياناتها وتعديلها ، يمكنك الوصول إلى البيانات الموجودة في الكائنات من خلال ما يسمى <code>properties</code> . تُعد الكائنات مفيدة لتخزين البيانات بطريقة منظمة ، ويمكن أن تمثل كائنات العالم الحقيقي ، مثل القطة. وإليك عينة كائن القط: <blockquote style=";text-align:right;direction:rtl"> var cat = { <br> "الاسم": "الشعيرات" ، <br> "الساقين": 4 ، <br> "ذيول": 1 ، <br> "الأعداء": ["Water"، "Dogs"] <br> }؛ </blockquote> في هذا المثال ، يتم تخزين جميع الخصائص كسلاسل ، مثل - <code>"name"</code> ، <code>"legs"</code> ، و <code>"tails"</code> . ومع ذلك ، يمكنك أيضًا استخدام الأرقام كخصائص. يمكنك حتى حذف علامات الاقتباس لخصائص السلسلة المفردة الكلمة ، كما يلي: <blockquote style=";text-align:right;direction:rtl"> var anotherObject = { <br> جعل: "فورد" ، <br> 5: "خمسة" ، <br> "نموذج": "التركيز" <br> }؛ </blockquote> ومع ذلك ، إذا كان الكائن الخاص بك يحتوي على أية خصائص غير سلسلة ، فسوف يقوم جافا سكريبت بتلبيسها تلقائيًا كسلاسل. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> جعل كائن يمثل كلب يسمى <code>myDog</code> الذي يحتوي على خصائص <code>"name"</code> (سلسلة) ، <code>"legs"</code> ، <code>"tails"</code> و <code>"friends"</code> . يمكنك تعيين خصائص الكائن هذه إلى أي قيم تريدها ، حيث أن <code>"name"</code> الطويل عبارة عن سلسلة ، و <code>"legs"</code> و <code>"tails"</code> هي أرقام ، و <code>"friends"</code> هو مصفوفة. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myDog</code> يجب أن يحتوي على <code>name</code> الخاصية ويجب أن يكون <code>string</code> .
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("name") && z.name !== undefined && typeof z.name === "string"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.");'
|
||||
- text: <code>myDog</code> يجب أن يحتوي على <code>legs</code> العقار ويجب أن يكون <code>number</code> .
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("legs") && z.legs !== undefined && typeof z.legs === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.");'
|
||||
- text: <code>myDog</code> يجب أن يحتوي على <code>tails</code> الخاصية ويجب أن يكون <code>number</code> .
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("tails") && z.tails !== undefined && typeof z.tails === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.");'
|
||||
- text: <code>myDog</code> يجب أن يحتوي على <code>friends</code> الملكية ويجب أن يكون <code>array</code> .
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("friends") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.");'
|
||||
- text: يجب أن يحتوي <code>myDog</code> على جميع الخصائص المحددة فقط.
|
||||
testString: 'assert((function(z){return Object.keys(z).length === 4;})(myDog), "<code>myDog</code> should only contain all the given properties.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourDog = {
|
||||
"name": "Camper",
|
||||
"legs": 4,
|
||||
"tails": 1,
|
||||
"friends": ["everything!"]
|
||||
};
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
var myDog = {
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244dc
|
||||
title: Chaining If Else Statements
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: تسلسل إذا كانت تصريحات أخرى
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> <code>if/else</code> يمكن ربط عبارات <code>if/else</code> معًا لمنطق معقد. هنا هو <dfn>pseudocode</dfn> متعددة متعددة السلاسل <code>if</code> / <code>else if</code> العبارات: <blockquote style=";text-align:right;direction:rtl"> إذا ( <em>condition1</em> ) { <br> <em>statement1</em> <br> } آخر إذا ( <em>condition2</em> ) { <br> <em>statement2</em> <br> } آخر إذا ( <em>condition3</em> ) { <br> <em>statement3</em> <br> . . . <br> } آخر { <br> <em>statementN</em> <br> } </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> كتابة مقيد <code>if</code> / <code>else if</code> عبارات تفي بالشروط التالية: <code>num < 5</code> - return "Tiny" <br> <code>num < 10</code> - عودة "صغير" <br> <code>num < 15</code> - عودة "متوسطة" <br> <code>num < 20</code> - عودة "كبير" <br> <code>num >= 20</code> - return "Huge" </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون لديك على الأقل أربع <code>else</code> البيانات
|
||||
testString: 'assert(code.match(/else/g).length > 3, "You should have at least four <code>else</code> statements");'
|
||||
- text: يجب أن يكون لديك أربعة على الأقل <code>if</code> البيانات
|
||||
testString: 'assert(code.match(/if/g).length > 3, "You should have at least four <code>if</code> statements");'
|
||||
- text: يجب أن يكون لديك بيان <code>return</code> واحد على الأقل
|
||||
testString: 'assert(code.match(/return/g).length >= 1, "You should have at least one <code>return</code> statement");'
|
||||
- text: يجب أن ترجع <code>testSize(0)</code> "صغيرة"
|
||||
testString: 'assert(testSize(0) === "Tiny", "<code>testSize(0)</code> should return "Tiny"");'
|
||||
- text: يجب أن ترجع <code>testSize(4)</code> "صغيرة"
|
||||
testString: 'assert(testSize(4) === "Tiny", "<code>testSize(4)</code> should return "Tiny"");'
|
||||
- text: <code>testSize(5)</code> إرجاع "صغير"
|
||||
testString: 'assert(testSize(5) === "Small", "<code>testSize(5)</code> should return "Small"");'
|
||||
- text: <code>testSize(8)</code> إرجاع "صغير"
|
||||
testString: 'assert(testSize(8) === "Small", "<code>testSize(8)</code> should return "Small"");'
|
||||
- text: <code>testSize(10)</code> إرجاع "Medium"
|
||||
testString: 'assert(testSize(10) === "Medium", "<code>testSize(10)</code> should return "Medium"");'
|
||||
- text: <code>testSize(14)</code> إرجاع "Medium"
|
||||
testString: 'assert(testSize(14) === "Medium", "<code>testSize(14)</code> should return "Medium"");'
|
||||
- text: <code>testSize(15)</code> إرجاع "كبير"
|
||||
testString: 'assert(testSize(15) === "Large", "<code>testSize(15)</code> should return "Large"");'
|
||||
- text: <code>testSize(17)</code> إرجاع "كبير"
|
||||
testString: 'assert(testSize(17) === "Large", "<code>testSize(17)</code> should return "Large"");'
|
||||
- text: <code>testSize(20)</code> إرجاع "ضخم"
|
||||
testString: 'assert(testSize(20) === "Huge", "<code>testSize(20)</code> should return "Huge"");'
|
||||
- text: <code>testSize(25)</code> إرجاع "ضخم"
|
||||
testString: 'assert(testSize(25) === "Huge", "<code>testSize(25)</code> should return "Huge"");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testSize(num) {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
return "Change Me";
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testSize(7);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,50 @@
|
||||
---
|
||||
id: bd7123c9c441eddfaeb4bdef
|
||||
title: Comment Your JavaScript Code
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: تعليق كود جافاسكريبت الخاص بك
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> التعليقات هي أسطر من التعليمات البرمجية التي ستتجاهلها JavaScript بشكل مقصود. تعتبر التعليقات طريقة رائعة لترك ملاحظاتك لنفسك وللأشخاص الآخرين الذين سيحتاجون لاحقًا لمعرفة ما يفعله هذا الرمز. هناك طريقتان لكتابة التعليقات في جافا سكريبت: سيخبر استخدام <code>//</code> جافا سكريبت JavaScript لتجاهل الجزء المتبقي من النص في السطر الحالي: <blockquote style=";text-align:right;direction:rtl"> // هذا تعليق مباشر. </blockquote> يمكنك إنشاء تعليق متعدد الأسطر يبدأ بـ <code>/*</code> وينتهي بـ <code>*/</code> : <blockquote style=";text-align:right;direction:rtl"> /* هذا ال <br> تعليق متعدد الخطوط * / </blockquote> <strong>افضل تمرين</strong> <br> أثناء كتابة التعليمة البرمجية ، يجب إضافة التعليقات بانتظام لتوضيح وظيفة أجزاء من التعليمات البرمجية. يمكن للتعليق الجيد أن يساعد في توصيل مقاصد رمزك - سواء بالنسبة للآخرين <em>أو</em> لمستقبلك. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> حاول إنشاء واحد من كل نوع من التعليقات. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: أنشئ تعليقًا بنمط <code>//</code> يحتوي على خمس رسائل على الأقل.
|
||||
testString: 'assert(code.match(/(\/\/)...../g), "Create a <code>//</code> style comment that contains at least five letters.");'
|
||||
- text: أنشئ تعليقًا بنمط <code>/* */</code> يحتوي على خمس رسائل على الأقل.
|
||||
testString: 'assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm), "Create a <code>/* */</code> style comment that contains at least five letters.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d0
|
||||
title: Comparison with the Equality Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنة مع مشغل المساواة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> هناك العديد من <dfn>مشغلي المقارنة</dfn> في JavaScript. كل هذه العوامل إرجاع منطقية <code>true</code> أو <code>false</code> القيمة. المشغل الأساسي هو مشغل المساواة <code>==</code> . يقارن عامل المساواة بين قيمتين ويعرض <code>true</code> إذا كانت مكافئة أو <code>false</code> إذا لم تكن كذلك. لاحظ أن المساواة تختلف عن الواجب ( <code>=</code> ) ، الذي يعين القيمة على يمين المشغل إلى متغير في اليسار. <blockquote style=";text-align:right;direction:rtl"> الوظيفة equalestTest (myVal) { <br> if (myVal == 10) { <br> العودة "يساوي" ؛ <br> } <br> "لا يساوي"؛ <br> } </blockquote> إذا كانت <code>myVal</code> تساوي <code>10</code> ، <code>myVal</code> عامل التساوي <code>true</code> ، لذا سيتم تنفيذ الشفرة في الأقواس المتعرجة ، وستعرض الدالة <code>"Equal"</code> . خلاف ذلك ، ستقوم الدالة بإرجاع <code>"Not Equal"</code> . لكي تتمكن JavaScript من مقارنة نوعين مختلفين من <code>data types</code> (على سبيل المثال ، <code>numbers</code> <code>strings</code> ) ، يجب أن تقوم بتحويل نوع واحد إلى آخر. هذا هو المعروف باسم "نوع الإكراه". وبمجرد الانتهاء من ذلك ، يمكن مقارنة الشروط كما يلي: <blockquote style=";text-align:right;direction:rtl"> 1 == 1 // true <br> 1 == 2 // false <br> 1 == '1' // true <br> "3" == 3 // true </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> أضف <code>equality operator</code> إلى الخط المحدد بحيث تقوم الدالة بإرجاع "Equal" عندما يكون <code>val</code> مساويًا لـ <code>12</code> </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testEqual(10)</code> يجب أن ترجع "غير مساوي"
|
||||
testString: 'assert(testEqual(10) === "Not Equal", "<code>testEqual(10)</code> should return "Not Equal"");'
|
||||
- text: <code>testEqual(12)</code> يجب أن ترجع "Equal"
|
||||
testString: 'assert(testEqual(12) === "Equal", "<code>testEqual(12)</code> should return "Equal"");'
|
||||
- text: <code>testEqual("12")</code> إرجاع "Equal"
|
||||
testString: 'assert(testEqual("12") === "Equal", "<code>testEqual("12")</code> should return "Equal"");'
|
||||
- text: يجب عليك استخدام عامل التشغيل <code>==</code>
|
||||
testString: 'assert(code.match(/==/g) && !code.match(/===/g), "You should use the <code>==</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
function testEqual(val) {
|
||||
if (val) { // Change this line
|
||||
return "Equal";
|
||||
}
|
||||
return "Not Equal";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testEqual(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d4
|
||||
title: Comparison with the Greater Than Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنة مع أكبر من المشغل
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> أكبر من المشغل ( <code>></code> ) يقارن قيم رقمين. إذا كان الرقم إلى اليسار أكبر من الرقم إلى اليمين ، فسيعود إلى <code>true</code> . خلاف ذلك ، فإنها ترجع <code>false</code> . مثل المشغل المساواة ، أكبر من المشغل سوف يحول أنواع البيانات من القيم في حين مقارنة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 5> 3 // صحيح <br> 7> '3' // true <br> 2> 3 // false <br> '1'> 9 // false </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة <code>greater than</code> المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن <code>testGreaterThan(0)</code> "10 أو أقل"
|
||||
testString: 'assert(testGreaterThan(0) === "10 or Under", "<code>testGreaterThan(0)</code> should return "10 or Under"");'
|
||||
- text: <code>testGreaterThan(10)</code> إرجاع "10 أو أقل"
|
||||
testString: 'assert(testGreaterThan(10) === "10 or Under", "<code>testGreaterThan(10)</code> should return "10 or Under"");'
|
||||
- text: يجب أن ترجع <code>testGreaterThan(11)</code> "أكثر من 10"
|
||||
testString: 'assert(testGreaterThan(11) === "Over 10", "<code>testGreaterThan(11)</code> should return "Over 10"");'
|
||||
- text: <code>testGreaterThan(99)</code> إرجاع "أكثر من 10"
|
||||
testString: 'assert(testGreaterThan(99) === "Over 10", "<code>testGreaterThan(99)</code> should return "Over 10"");'
|
||||
- text: <code>testGreaterThan(100)</code> إرجاع "أكثر من 10"
|
||||
testString: 'assert(testGreaterThan(100) === "Over 10", "<code>testGreaterThan(100)</code> should return "Over 10"");'
|
||||
- text: <code>testGreaterThan(101)</code> إرجاع "أكثر من 100"
|
||||
testString: 'assert(testGreaterThan(101) === "Over 100", "<code>testGreaterThan(101)</code> should return "Over 100"");'
|
||||
- text: <code>testGreaterThan(150)</code> إرجاع "أكثر من 100"
|
||||
testString: 'assert(testGreaterThan(150) === "Over 100", "<code>testGreaterThan(150)</code> should return "Over 100"");'
|
||||
- text: يجب عليك استخدام <code>></code> مشغل على الأقل مرتين
|
||||
testString: 'assert(code.match(/val\s*>\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>></code> operator at least twice");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testGreaterThan(val) {
|
||||
if (val) { // Change this line
|
||||
return "Over 100";
|
||||
}
|
||||
|
||||
if (val) { // Change this line
|
||||
return "Over 10";
|
||||
}
|
||||
|
||||
return "10 or Under";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testGreaterThan(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d5
|
||||
title: Comparison with the Greater Than Or Equal To Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنة مع أكبر من أو يساوي المشغل
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يقارن العامل <code>greater than or equal to</code> ( <code>>=</code> ) قيم رقمين. إذا كان الرقم إلى اليسار أكبر من أو يساوي الرقم إلى اليمين ، فإنه يُرجع <code>true</code> . خلاف ذلك ، فإنها ترجع <code>false</code> . مثل مشغل عامل المساواة ، فإن <code>greater than or equal to</code> المشغل سيقوم بتحويل أنواع البيانات أثناء المقارنة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 6> = 6 // true <br> 7> = '3' // true <br> 2> = 3 // false <br> '7'> = 9 // false </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة <code>greater than or equal to</code> المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن <code>testGreaterOrEqual(0)</code> "أقل من 10"
|
||||
testString: 'assert(testGreaterOrEqual(0) === "Less than 10", "<code>testGreaterOrEqual(0)</code> should return "Less than 10"");'
|
||||
- text: <code>testGreaterOrEqual(9)</code> إرجاع "أقل من 10"
|
||||
testString: 'assert(testGreaterOrEqual(9) === "Less than 10", "<code>testGreaterOrEqual(9)</code> should return "Less than 10"");'
|
||||
- text: يجب أن <code>testGreaterOrEqual(10)</code> "10 أو أكثر"
|
||||
testString: 'assert(testGreaterOrEqual(10) === "10 or Over", "<code>testGreaterOrEqual(10)</code> should return "10 or Over"");'
|
||||
- text: <code>testGreaterOrEqual(11)</code> إرجاع "10 أو أكثر"
|
||||
testString: 'assert(testGreaterOrEqual(11) === "10 or Over", "<code>testGreaterOrEqual(11)</code> should return "10 or Over"");'
|
||||
- text: <code>testGreaterOrEqual(19)</code> إرجاع "10 أو أكثر"
|
||||
testString: 'assert(testGreaterOrEqual(19) === "10 or Over", "<code>testGreaterOrEqual(19)</code> should return "10 or Over"");'
|
||||
- text: يجب أن <code>testGreaterOrEqual(100)</code> "20 أو أكثر"
|
||||
testString: 'assert(testGreaterOrEqual(100) === "20 or Over", "<code>testGreaterOrEqual(100)</code> should return "20 or Over"");'
|
||||
- text: <code>testGreaterOrEqual(21)</code> إرجاع "20 أو أكثر"
|
||||
testString: 'assert(testGreaterOrEqual(21) === "20 or Over", "<code>testGreaterOrEqual(21)</code> should return "20 or Over"");'
|
||||
- text: يجب عليك استخدام <code>>=</code> عامل التشغيل على الأقل مرتين
|
||||
testString: 'assert(code.match(/val\s*>=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>>=</code> operator at least twice");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testGreaterOrEqual(val) {
|
||||
if (val) { // Change this line
|
||||
return "20 or Over";
|
||||
}
|
||||
|
||||
if (val) { // Change this line
|
||||
return "10 or Over";
|
||||
}
|
||||
|
||||
return "Less than 10";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testGreaterOrEqual(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d2
|
||||
title: Comparison with the Inequality Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنة مع مشغل عدم المساواة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> عامل عدم المساواة ( <code>!=</code> ) هو عكس مشغل المساواة. يعني "غير متساوٍ" ويعيد <code>false</code> حيث أن المساواة ستعود <code>true</code> <em>والعكس صحيح</em> . وعلى غرار مشغل المساواة ، يقوم مشغل عدم المساواة بتحويل أنواع البيانات من القيم عند المقارنة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 1! = 2 / صحيح <br> 1! = "1" // false <br> 1! = '1' // false <br> 1! = true // false <br> 0! = false // false </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة عامل عدم المساواة <code>!=</code> في جملة <code>if</code> بحيث تقوم الدالة بإرجاع "غير مساوي" عندما لا يكون <code>val</code> مساوياً لـ <code>99</code> </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testNotEqual(99)</code> يجب أن ترجع "Equal"
|
||||
testString: 'assert(testNotEqual(99) === "Equal", "<code>testNotEqual(99)</code> should return "Equal"");'
|
||||
- text: <code>testNotEqual("99")</code> يجب أن يقوم بإرجاع "Equal"
|
||||
testString: 'assert(testNotEqual("99") === "Equal", "<code>testNotEqual("99")</code> should return "Equal"");'
|
||||
- text: يجب أن <code>testNotEqual(12)</code> "غير مساوي"
|
||||
testString: 'assert(testNotEqual(12) === "Not Equal", "<code>testNotEqual(12)</code> should return "Not Equal"");'
|
||||
- text: <code>testNotEqual("12")</code> "غير مساوي"
|
||||
testString: 'assert(testNotEqual("12") === "Not Equal", "<code>testNotEqual("12")</code> should return "Not Equal"");'
|
||||
- text: <code>testNotEqual("bob")</code> "غير مساوي"
|
||||
testString: 'assert(testNotEqual("bob") === "Not Equal", "<code>testNotEqual("bob")</code> should return "Not Equal"");'
|
||||
- text: يجب عليك استخدام <code>!=</code> عامل التشغيل
|
||||
testString: 'assert(code.match(/(?!!==)!=/), "You should use the <code>!=</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
function testNotEqual(val) {
|
||||
if (val) { // Change this line
|
||||
return "Not Equal";
|
||||
}
|
||||
return "Equal";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testNotEqual(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d6
|
||||
title: Comparison with the Less Than Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنة مع أقل من المشغل
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يقارن <dfn>أقل من</dfn> المشغل ( <code><</code> ) قيم رقمين. إذا كان الرقم إلى اليسار أقل من الرقم إلى اليمين ، فسيعود إلى الحالة <code>true</code> . خلاف ذلك ، فإنها ترجع <code>false</code> . مثل المشغل المساواة ، <dfn>أقل من</dfn> المشغل يحول أنواع البيانات أثناء مقارنة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 2 <5 / صحيح <br> "3" <7 // صحيح <br> 5 <5 // خاطئة <br> 3 <2 // false <br> "8" <4 // كاذبة </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة <code>less than</code> المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن ترجع <code>testLessThan(0)</code> "تحت 25"
|
||||
testString: 'assert(testLessThan(0) === "Under 25", "<code>testLessThan(0)</code> should return "Under 25"");'
|
||||
- text: يجب أن ترجع <code>testLessThan(24)</code> "تحت 25"
|
||||
testString: 'assert(testLessThan(24) === "Under 25", "<code>testLessThan(24)</code> should return "Under 25"");'
|
||||
- text: يجب أن ترجع <code>testLessThan(25)</code> "تحت 55"
|
||||
testString: 'assert(testLessThan(25) === "Under 55", "<code>testLessThan(25)</code> should return "Under 55"");'
|
||||
- text: يجب أن ترجع <code>testLessThan(54)</code> "تحت 55"
|
||||
testString: 'assert(testLessThan(54) === "Under 55", "<code>testLessThan(54)</code> should return "Under 55"");'
|
||||
- text: <code>testLessThan(55)</code> إرجاع "55 أو أكثر"
|
||||
testString: 'assert(testLessThan(55) === "55 or Over", "<code>testLessThan(55)</code> should return "55 or Over"");'
|
||||
- text: يجب أن ترجع <code>testLessThan(99)</code> "55 أو أكثر"
|
||||
testString: 'assert(testLessThan(99) === "55 or Over", "<code>testLessThan(99)</code> should return "55 or Over"");'
|
||||
- text: يجب عليك استخدام <code><</code> المشغل مرتين على الأقل
|
||||
testString: 'assert(code.match(/val\s*<\s*("|")*\d+("|")*/g).length > 1, "You should use the <code><</code> operator at least twice");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testLessThan(val) {
|
||||
if (val) { // Change this line
|
||||
return "Under 25";
|
||||
}
|
||||
|
||||
if (val) { // Change this line
|
||||
return "Under 55";
|
||||
}
|
||||
|
||||
return "55 or Over";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testLessThan(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d7
|
||||
title: Comparison with the Less Than Or Equal To Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنة مع أقل من أو يساوي المشغل
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يقارن <code>less than or equal to</code> المشغل ( <code><=</code> ) قيم رقمين. إذا كان الرقم إلى اليسار أقل من أو يساوي الرقم إلى اليمين ، فسيعود إلى <code>true</code> . إذا كان الرقم الموجود على اليسار أكبر من الرقم الموجود على اليمين ، فسيعرض <code>false</code> . مثل مشغل المساواة ، <code>less than or equal to</code> تحويل أنواع البيانات. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 4 <= 5 // صحيح <br> "7" <= 7 // صحيح <br> 5 <= 5 // صحيح <br> 3 <= 2 // خطأ <br> "8" <= 4 // كاذبة </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة <code>less than or equal to</code> المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن ترجع <code>testLessOrEqual(0)</code> "Smaller Than أو Equal إلى 12"
|
||||
testString: 'assert(testLessOrEqual(0) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"");'
|
||||
- text: يجب أن ترجع <code>testLessOrEqual(11)</code> "أصغر من أو يساوي إلى 12"
|
||||
testString: 'assert(testLessOrEqual(11) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"");'
|
||||
- text: يجب أن ترجع <code>testLessOrEqual(12)</code> "Smaller Than أو Equal إلى 12"
|
||||
testString: 'assert(testLessOrEqual(12) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"");'
|
||||
- text: يجب أن ترجع <code>testLessOrEqual(23)</code> "Smaller Than أو Equal إلى 24"
|
||||
testString: 'assert(testLessOrEqual(23) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"");'
|
||||
- text: يجب أن ترجع <code>testLessOrEqual(24)</code> "Smaller Than أو Equal إلى 24"
|
||||
testString: 'assert(testLessOrEqual(24) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"");'
|
||||
- text: يجب أن ترجع <code>testLessOrEqual(25)</code> "أكثر من 24"
|
||||
testString: 'assert(testLessOrEqual(25) === "More Than 24", "<code>testLessOrEqual(25)</code> should return "More Than 24"");'
|
||||
- text: يجب أن ترجع <code>testLessOrEqual(55)</code> "أكثر من 24"
|
||||
testString: 'assert(testLessOrEqual(55) === "More Than 24", "<code>testLessOrEqual(55)</code> should return "More Than 24"");'
|
||||
- text: يجب عليك استخدام <code><=</code> عامل التشغيل على الأقل مرتين
|
||||
testString: 'assert(code.match(/val\s*<=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code><=</code> operator at least twice");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testLessOrEqual(val) {
|
||||
if (val) { // Change this line
|
||||
return "Smaller Than or Equal to 12";
|
||||
}
|
||||
|
||||
if (val) { // Change this line
|
||||
return "Smaller Than or Equal to 24";
|
||||
}
|
||||
|
||||
return "More Than 24";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testLessOrEqual(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d1
|
||||
title: Comparison with the Strict Equality Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنة مع مشغل المساواة الصارمة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> المساواة <code>===</code> ( <code>===</code> ) هي نظير مشغل المساواة ( <code>==</code> ). ومع ذلك ، على عكس مشغل المساواة ، الذي يحاول تحويل كلتا القيمتين مقارنة بالنوع الشائع ، فإن مشغل المساواة الصارم لا يقوم بتحويل نوع. إذا كانت القيم التي يتم مقارنتها لها أنواع مختلفة ، فإنها تعتبر غير متساوية ، وسيعود المشغل الصارم للمساواة كاذبة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 3 === 3 // true <br> 3 === '3' // false </blockquote> في المثال الثاني ، <code>3</code> هو نوع <code>Number</code> و <code>'3'</code> هو نوع <code>String</code> . </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استخدم عامل التساوي الصارم في العبارة <code>if</code> بحيث تقوم الدالة بإرجاع "Equal" عندما تكون <code>val</code> تساوي تمامًا <code>7</code> </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن ترجع <code>testStrict(10)</code> "غير مساوي"
|
||||
testString: 'assert(testStrict(10) === "Not Equal", "<code>testStrict(10)</code> should return "Not Equal"");'
|
||||
- text: <code>testStrict(7)</code> إرجاع "Equal"
|
||||
testString: 'assert(testStrict(7) === "Equal", "<code>testStrict(7)</code> should return "Equal"");'
|
||||
- text: <code>testStrict("7")</code> إرجاع "غير مساوي"
|
||||
testString: 'assert(testStrict("7") === "Not Equal", "<code>testStrict("7")</code> should return "Not Equal"");'
|
||||
- text: يجب عليك استخدام عامل التشغيل <code>===</code>
|
||||
testString: 'assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0, "You should use the <code>===</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
function testStrict(val) {
|
||||
if (val) { // Change this line
|
||||
return "Equal";
|
||||
}
|
||||
return "Not Equal";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testStrict(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d3
|
||||
title: Comparison with the Strict Inequality Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنة مع مشغل عدم المساواة الصارم
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> إن عامل عدم المساواة الصارم ( <code>!==</code> ) هو المقابل المنطقي للمشغل الصارم للمساواة. ويعني "عدم التساوي في الدقة" ويعود <code>false</code> حيث تعود المساواة الصارمة إلى <code>true</code> <em>والعكس صحيح</em> . عدم المساواة الصارمة لن تقوم بتحويل أنواع البيانات. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 3! == 3 // false <br> 3! == '3' // true <br> 4! == 3 // صحيح </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة <code>strict inequality operator</code> إلى العبارة <code>if</code> بحيث تقوم الدالة بإرجاع "غير مساوي" عندما لا يكون <code>val</code> مساوياً تمامًا لـ <code>17</code> </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testStrictNotEqual(17)</code> إرجاع "مساواة"
|
||||
testString: 'assert(testStrictNotEqual(17) === "Equal", "<code>testStrictNotEqual(17)</code> should return "Equal"");'
|
||||
- text: <code>testStrictNotEqual("17")</code> "غير مساوي"
|
||||
testString: 'assert(testStrictNotEqual("17") === "Not Equal", "<code>testStrictNotEqual("17")</code> should return "Not Equal"");'
|
||||
- text: يجب أن <code>testStrictNotEqual(12)</code> "غير مساوي"
|
||||
testString: 'assert(testStrictNotEqual(12) === "Not Equal", "<code>testStrictNotEqual(12)</code> should return "Not Equal"");'
|
||||
- text: <code>testStrictNotEqual("bob")</code> "غير مساوي"
|
||||
testString: 'assert(testStrictNotEqual("bob") === "Not Equal", "<code>testStrictNotEqual("bob")</code> should return "Not Equal"");'
|
||||
- text: يجب عليك استخدام <code>!==</code> المشغل
|
||||
testString: 'assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0, "You should use the <code>!==</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
function testStrictNotEqual(val) {
|
||||
// Only Change Code Below this Line
|
||||
|
||||
if (val) {
|
||||
|
||||
// Only Change Code Above this Line
|
||||
|
||||
return "Not Equal";
|
||||
}
|
||||
return "Equal";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testStrictNotEqual(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d8
|
||||
title: Comparisons with the Logical And Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنات مع المنطقية والمشغل
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في بعض الأحيان ستحتاج إلى اختبار أكثر من شيء واحد في كل مرة. إرجاع <dfn>المنطقية</dfn> والمشغل ( <code>&&</code> ) <code>true</code> إذا وفقط إذا كانت <dfn>المعاملات</dfn> إلى اليسار واليمين صحيحاً. يمكن تحقيق نفس التأثير بتضمين جملة if داخل أخرى إذا: <blockquote style=";text-align:right;direction:rtl"> if (num> 5) { <br> إذا (عدد <10) { <br> العودة "نعم" ؛ <br> } <br> } <br> العودة "لا" ؛ </blockquote> سيعود فقط "نعم" إذا <code>num</code> أكبر من <code>5</code> وأقل من <code>10</code> . نفس المنطق يمكن كتابته على النحو التالي: <blockquote style=";text-align:right;direction:rtl"> if (num> 5 & num <10) { <br> العودة "نعم" ؛ <br> } <br> العودة "لا" ؛ </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بدمج العبارة "if" في عبارة واحدة والتي ستُرجع <code>"Yes"</code> إذا كان <code>val</code> أقل من أو يساوي <code>50</code> وأكبر من أو يساوي <code>25</code> . خلاف ذلك ، سيعود <code>"No"</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب عليك استخدام مشغل <code>&&</code> مرة واحدة
|
||||
testString: 'assert(code.match(/&&/g).length === 1, "You should use the <code>&&</code> operator once");'
|
||||
- text: يجب أن يكون لديك واحد فقط <code>if</code> البيان
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
|
||||
- text: يجب أن ترجع <code>testLogicalAnd(0)</code> "لا"
|
||||
testString: 'assert(testLogicalAnd(0) === "No", "<code>testLogicalAnd(0)</code> should return "No"");'
|
||||
- text: <code>testLogicalAnd(24)</code> يجب أن ترجع "لا"
|
||||
testString: 'assert(testLogicalAnd(24) === "No", "<code>testLogicalAnd(24)</code> should return "No"");'
|
||||
- text: <code>testLogicalAnd(25)</code> يجب أن ترجع "Yes"
|
||||
testString: 'assert(testLogicalAnd(25) === "Yes", "<code>testLogicalAnd(25)</code> should return "Yes"");'
|
||||
- text: يجب أن ترجع <code>testLogicalAnd(30)</code> "نعم"
|
||||
testString: 'assert(testLogicalAnd(30) === "Yes", "<code>testLogicalAnd(30)</code> should return "Yes"");'
|
||||
- text: يجب أن ترجع <code>testLogicalAnd(50)</code> "نعم"
|
||||
testString: 'assert(testLogicalAnd(50) === "Yes", "<code>testLogicalAnd(50)</code> should return "Yes"");'
|
||||
- text: <code>testLogicalAnd(51)</code> يجب أن ترجع "لا"
|
||||
testString: 'assert(testLogicalAnd(51) === "No", "<code>testLogicalAnd(51)</code> should return "No"");'
|
||||
- text: يجب أن <code>testLogicalAnd(75)</code> "لا"
|
||||
testString: 'assert(testLogicalAnd(75) === "No", "<code>testLogicalAnd(75)</code> should return "No"");'
|
||||
- text: <code>testLogicalAnd(80)</code> يجب أن ترجع "لا"
|
||||
testString: 'assert(testLogicalAnd(80) === "No", "<code>testLogicalAnd(80)</code> should return "No"");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testLogicalAnd(val) {
|
||||
// Only change code below this line
|
||||
|
||||
if (val) {
|
||||
if (val) {
|
||||
return "Yes";
|
||||
}
|
||||
}
|
||||
|
||||
// Only change code above this line
|
||||
return "No";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testLogicalAnd(10);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,83 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d9
|
||||
title: Comparisons with the Logical Or Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مقارنات مع المنطقي أو المشغل
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> إرجاع <dfn>المنطقية أو</dfn> عامل التشغيل ( <code>||</code> ) <code>true</code> إذا كان أي من <dfn>المعاملات</dfn> <code>true</code> . خلاف ذلك ، فإنها ترجع <code>false</code> . <dfn>المنطقي أو</dfn> المشغل يتكون من اثنين من رموز الأنبوب ( <code>|</code> ). يمكن العثور على ذلك عادةً بين مفتاحي Backspace و Enter. يجب أن يبدو النمط أدناه مألوفًا من نقاط الطريق السابقة: <blockquote style=";text-align:right;direction:rtl"> if (num> 10) { <br> العودة "لا" ؛ <br> } <br> إذا (عدد <5) { <br> العودة "لا" ؛ <br> } <br> العودة "نعم" ؛ </blockquote> سيعود "نعم" إلا إذا <code>num</code> ما بين <code>5</code> و <code>10</code> (5 و 10 مدرجة). نفس المنطق يمكن كتابته على النحو التالي: <blockquote style=";text-align:right;direction:rtl"> if (num> 10 || num <5) { <br> العودة "لا" ؛ <br> } <br> العودة "نعم" ؛ </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> اجمع بين العبارة " <code>if</code> في عبارة واحدة والتي تُرجع <code>"Outside"</code> إذا لم يكن <code>val</code> ما بين <code>10</code> و <code>20</code> ضمناً. خلاف ذلك ، والعودة <code>"Inside"</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب عليك استخدام <code>||</code> عامل مرة واحدة
|
||||
testString: 'assert(code.match(/\|\|/g).length === 1, "You should use the <code>||</code> operator once");'
|
||||
- text: يجب أن يكون لديك واحد فقط <code>if</code> البيان
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
|
||||
- text: يجب أن ترجع <code>testLogicalOr(0)</code> "خارج"
|
||||
testString: 'assert(testLogicalOr(0) === "Outside", "<code>testLogicalOr(0)</code> should return "Outside"");'
|
||||
- text: يجب أن ترجع <code>testLogicalOr(9)</code> "خارج"
|
||||
testString: 'assert(testLogicalOr(9) === "Outside", "<code>testLogicalOr(9)</code> should return "Outside"");'
|
||||
- text: <code>testLogicalOr(10)</code> إرجاع "Inside"
|
||||
testString: 'assert(testLogicalOr(10) === "Inside", "<code>testLogicalOr(10)</code> should return "Inside"");'
|
||||
- text: <code>testLogicalOr(15)</code> إرجاع "Inside"
|
||||
testString: 'assert(testLogicalOr(15) === "Inside", "<code>testLogicalOr(15)</code> should return "Inside"");'
|
||||
- text: <code>testLogicalOr(19)</code> إرجاع "Inside"
|
||||
testString: 'assert(testLogicalOr(19) === "Inside", "<code>testLogicalOr(19)</code> should return "Inside"");'
|
||||
- text: <code>testLogicalOr(20)</code> إرجاع "Inside"
|
||||
testString: 'assert(testLogicalOr(20) === "Inside", "<code>testLogicalOr(20)</code> should return "Inside"");'
|
||||
- text: يجب أن ترجع <code>testLogicalOr(21)</code> "خارج"
|
||||
testString: 'assert(testLogicalOr(21) === "Outside", "<code>testLogicalOr(21)</code> should return "Outside"");'
|
||||
- text: يجب أن ترجع <code>testLogicalOr(25)</code> "خارج"
|
||||
testString: 'assert(testLogicalOr(25) === "Outside", "<code>testLogicalOr(25)</code> should return "Outside"");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testLogicalOr(val) {
|
||||
// Only change code below this line
|
||||
|
||||
if (val) {
|
||||
return "Outside";
|
||||
}
|
||||
|
||||
if (val) {
|
||||
return "Outside";
|
||||
}
|
||||
|
||||
// Only change code above this line
|
||||
return "Inside";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testLogicalOr(15);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244af
|
||||
title: Compound Assignment With Augmented Addition
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مهمة مركبة مع إضافة مضافة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في البرمجة ، من الشائع استخدام التعيينات لتعديل محتويات المتغير. تذكر أن كل شيء على يمين علامة المساواة يتم تقييمه أولاً ، حتى يمكننا قول: <code>myVar = myVar + 5;</code> لإضافة <code>5</code> إلى <code>myVar</code> . بما أن هذا هو النمط الشائع ، فهناك مشغلين يقومون بعملية رياضية وتعيين في خطوة واحدة. أحد هذه المشغلات هو عامل <code>+=</code> . <blockquote style=";text-align:right;direction:rtl"> var myVar = 1 ، <br> myVar + = 5؛ <br> console.log (myVar)؛ // إرجاع 6 </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بتحويل التعيينات لـ <code>a</code> و <code>b</code> و <code>c</code> لاستخدام <code>+=</code> عامل التشغيل. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code> يجب أن يساوي <code>15</code>
|
||||
testString: 'assert(a === 15, "<code>a</code> should equal <code>15</code>");'
|
||||
- text: <code>b</code> يجب أن تساوي <code>26</code>
|
||||
testString: 'assert(b === 26, "<code>b</code> should equal <code>26</code>");'
|
||||
- text: <code>c</code> يجب أن تساوي <code>19</code>
|
||||
testString: 'assert(c === 19, "<code>c</code> should equal <code>19</code>");'
|
||||
- text: يجب عليك استخدام <code>+=</code> عامل لكل متغير
|
||||
testString: 'assert(code.match(/\+=/g).length === 3, "You should use the <code>+=</code> operator for each variable");'
|
||||
- text: لا تعدّل الشفرة فوق الخط
|
||||
testString: 'assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), "Do not modify the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var a = 3;
|
||||
var b = 17;
|
||||
var c = 12;
|
||||
|
||||
// Only modify code below this line
|
||||
|
||||
a = a + 12;
|
||||
b = 9 + b;
|
||||
c = c + 7;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b2
|
||||
title: Compound Assignment With Augmented Division
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: تكليف مركب مع قسم معزز
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يقوم عامل التشغيل <code>/=</code> بتقسيم متغير برقم آخر. <code>myVar = myVar / 5;</code> سوف يقسم <code>myVar</code> بنسبة <code>5</code> . يمكن إعادة كتابة هذا كـ: <code>myVar /= 5;</code> </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بتحويل التعيينات لـ <code>a</code> و <code>b</code> و <code>c</code> لاستخدام <code>/=</code> operator. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code> يجب أن يساوي <code>4</code>
|
||||
testString: 'assert(a === 4, "<code>a</code> should equal <code>4</code>");'
|
||||
- text: <code>b</code> يجب أن تساوي <code>27</code>
|
||||
testString: 'assert(b === 27, "<code>b</code> should equal <code>27</code>");'
|
||||
- text: <code>c</code> يجب أن يساوي <code>3</code>
|
||||
testString: 'assert(c === 3, "<code>c</code> should equal <code>3</code>");'
|
||||
- text: يجب عليك استخدام عامل التشغيل <code>/=</code> لكل متغير
|
||||
testString: 'assert(code.match(/\/=/g).length === 3, "You should use the <code>/=</code> operator for each variable");'
|
||||
- text: لا تعدّل الشفرة فوق الخط
|
||||
testString: 'assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code), "Do not modify the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var a = 48;
|
||||
var b = 108;
|
||||
var c = 33;
|
||||
|
||||
// Only modify code below this line
|
||||
|
||||
a = a / 12;
|
||||
b = b / 4;
|
||||
c = c / 11;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b1
|
||||
title: Compound Assignment With Augmented Multiplication
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مهمة مركبة مع تكاثر مضاعف
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يقوم عامل التشغيل <code>*=</code> بضرب متغير برقم. <code>myVar = myVar * 5;</code> سوف تضاعف <code>myVar</code> بنسبة <code>5</code> . يمكن إعادة كتابة هذا كـ: <code>myVar *= 5;</code> </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بتحويل التعيينات لـ <code>a</code> و <code>b</code> و <code>c</code> لاستخدام <code>*=</code> operator. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code> يجب أن يساوي <code>25</code>
|
||||
testString: 'assert(a === 25, "<code>a</code> should equal <code>25</code>");'
|
||||
- text: <code>b</code> يجب أن تساوي <code>36</code>
|
||||
testString: 'assert(b === 36, "<code>b</code> should equal <code>36</code>");'
|
||||
- text: <code>c</code> يجب أن تساوي <code>46</code>
|
||||
testString: 'assert(c === 46, "<code>c</code> should equal <code>46</code>");'
|
||||
- text: يجب عليك استخدام عامل التشغيل <code>*=</code> لكل متغير
|
||||
testString: 'assert(code.match(/\*=/g).length === 3, "You should use the <code>*=</code> operator for each variable");'
|
||||
- text: لا تعدّل الشفرة فوق الخط
|
||||
testString: 'assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code), "Do not modify the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var a = 5;
|
||||
var b = 12;
|
||||
var c = 4.6;
|
||||
|
||||
// Only modify code below this line
|
||||
|
||||
a = a * 5;
|
||||
b = 3 * b;
|
||||
c = c * 10;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b0
|
||||
title: Compound Assignment With Augmented Subtraction
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: مهمة مركبة مع الطرح المعزز
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> مثل <code>+=</code> عامل التشغيل ، <code>-=</code> طرح عدد من متغير. <code>myVar = myVar - 5;</code> سوف طرح <code>5</code> من <code>myVar</code> . يمكن إعادة كتابة هذا كـ: <code>myVar -= 5;</code> </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بتحويل التعيينات لـ <code>a</code> و <code>b</code> و <code>c</code> لاستخدام عامل التشغيل <code>-=</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code> يجب أن يساوي <code>5</code>
|
||||
testString: 'assert(a === 5, "<code>a</code> should equal <code>5</code>");'
|
||||
- text: <code>b</code> ينبغي أن تساوي <code>-6</code>
|
||||
testString: 'assert(b === -6, "<code>b</code> should equal <code>-6</code>");'
|
||||
- text: <code>c</code> يجب أن تساوي <code>2</code>
|
||||
testString: 'assert(c === 2, "<code>c</code> should equal <code>2</code>");'
|
||||
- text: يجب عليك استخدام <code>-=</code> عامل لكل متغير
|
||||
testString: 'assert(code.match(/-=/g).length === 3, "You should use the <code>-=</code> operator for each variable");'
|
||||
- text: لا تعدّل الشفرة فوق الخط
|
||||
testString: 'assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code), "Do not modify the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var a = 11;
|
||||
var b = 9;
|
||||
var c = 3;
|
||||
|
||||
// Only modify code below this line
|
||||
|
||||
a = a - 6;
|
||||
b = b - 15;
|
||||
c = c - 1;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b7
|
||||
title: Concatenating Strings with Plus Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: سلاسل متسلسلة مع Plus Operator
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في JavaScript ، عندما يتم استخدام عامل التشغيل <code>+</code> مع قيمة <code>String</code> ، يطلق عليه عامل التشغيل <dfn>السلسة</dfn> . يمكنك إنشاء سلسلة جديدة خارج السلاسل الأخرى عن طريق <dfn>وصلها</dfn> معًا. <strong>مثال</strong> <blockquote style=";text-align:right;direction:rtl"> "اسمي ألان ،" + "أنا سلسلته". </blockquote> <strong>ملحوظة</strong> <br> احترس من المساحات. لا يضيف Concatenation فراغات بين السلاسل المتسلسلة ، لذا ستحتاج إلى إضافتها بنفسك. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> بناء <code>myStr</code> من السلاسل <code>"This is the start. "</code> و <code>"This is the end."</code> باستخدام عامل <code>+</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون لـ <code>myStr</code> قيمة <code>This is the start. This is the end.</code>
|
||||
testString: 'assert(myStr === "This is the start. This is the end.", "<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>");'
|
||||
- text: استخدم عامل التشغيل <code>+</code> لبناء <code>myStr</code>
|
||||
testString: 'assert(code.match(/([""]).*([""])\s*\+\s*([""]).*([""])/g).length > 1, "Use the <code>+</code> operator to build <code>myStr</code>");'
|
||||
- text: يجب إنشاء <code>myStr</code> باستخدام الكلمة الرئيسية <code>var</code> .
|
||||
testString: 'assert(/var\s+myStr/.test(code), "<code>myStr</code> should be created using the <code>var</code> keyword.");'
|
||||
- text: تأكد من تعيين النتيجة لمتغير <code>myStr</code> .
|
||||
testString: 'assert(/myStr\s*=/.test(code), "Make sure to assign the result to the <code>myStr</code> variable.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourStr = "I come first. " + "I come second.";
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
var myStr;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b8
|
||||
title: Concatenating Strings with the Plus Equals Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: سلاسل متسلسلة مع Plus Equals Operator
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكننا أيضًا استخدام <code>+=</code> operator <dfn>لسَلسَلة</dfn> سلسلة في نهاية متغير سلسلة موجود. يمكن أن يكون هذا مفيدًا جدًا لكسر سلسلة طويلة عبر عدة أسطر. <strong>ملحوظة</strong> <br> احترس من المساحات. لا يضيف Concatenation فراغات بين السلاسل المتسلسلة ، لذا ستحتاج إلى إضافتها بنفسك. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إنشاء <code>myStr</code> عبر عدة سطور عن طريق وصل هاتين السلسلتين: <code>"This is the first sentence. "</code> و <code>"This is the second sentence."</code> باستخدام <code>+=</code> عامل التشغيل. استخدم <code>+=</code> عامل مشابه لكيفية ظهوره في المحرر. ابدأ بتخصيص السلسلة الأولى إلى <code>myStr</code> ، ثم أضفها في السلسلة الثانية. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون لـ <code>myStr</code> قيمة <code>This is the first sentence. This is the second sentence.</code>
|
||||
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>");'
|
||||
- text: استخدم <code>+=</code> عامل لبناء <code>myStr</code>
|
||||
testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the <code>+=</code> operator to build <code>myStr</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourStr = "I come first. ";
|
||||
ourStr += "I come second.";
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
var myStr;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b9
|
||||
title: Constructing Strings with Variables
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: بناء سلاسل مع المتغيرات
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في بعض الأحيان سوف تحتاج إلى بناء سلسلة ، نمط <a href="https://en.wikipedia.org/wiki/Mad_Libs" target="_blank">Mad Libs</a> . باستخدام عامل التشغيل السلسة ( <code>+</code> ) ، يمكنك إدراج متغير واحد أو أكثر في سلسلة تقوم ببنائها. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> تعيين <code>myName</code> إلى سلسلة يساوي اسمك وبناء <code>myStr</code> مع <code>myName</code> بين الجمل <code>"My name is "</code> و <code>" and I am well!"</code> </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب تعيين <code>myName</code> إلى سلسلة لا تقل عن 3 أحرف
|
||||
testString: 'assert(typeof myName !== "undefined" && myName.length > 2, "<code>myName</code> should be set to a string at least 3 characters long");'
|
||||
- text: استخدام اثنين <code>+</code> المشغلين لبناء <code>myStr</code> مع <code>myName</code> داخله
|
||||
testString: 'assert(code.match(/[""]\s*\+\s*myName\s*\+\s*[""]/g).length > 0, "Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourName = "freeCodeCamp";
|
||||
var ourStr = "Hello, our name is " + ourName + ", how are you?";
|
||||
|
||||
// Only change code below this line
|
||||
var myName;
|
||||
var myStr;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: 56105e7b514f539506016a5e
|
||||
title: Count Backwards With a For Loop
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: عد إلى الخلف مع ل حلقة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكن أيضًا حساب العروة للخلف ، طالما أننا نستطيع تحديد الشروط الصحيحة. من أجل احتساب العكسيتين بعلامة twos ، سنحتاج إلى تغيير <code>initialization</code> <code>condition</code> <code>final-expression</code> . سنبدأ عند <code>i = 10</code> والحلقة بينما <code>i > 0</code> . سنقوم decrement <code>i</code> كل حلقة 2 مع <code>i -= 2</code> . <blockquote style=";text-align:right;direction:rtl"> var ourArray = []؛ <br> for (var i = 10؛ i> 0؛ i- = 2) { <br> ourArray.push (ط)؛ <br> } </blockquote> <code>ourArray</code> الآن <code>[10,8,6,4,2]</code> . دعونا نغير <code>initialization</code> <code>final-expression</code> حتى نتمكن من العد إلى الوراء من خلال الاثنتين بالأرقام الفردية. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> ادفع الأرقام الفردية من 9 إلى 1 إلى <code>myArray</code> باستخدام حلقة <code>for</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تكون باستخدام <code>for</code> حلقة لهذا الغرض.
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
- text: يجب أن تستخدم <code>push</code> طريقة الصفيف.
|
||||
testString: 'assert(code.match(/myArray.push/), "You should be using the array method <code>push</code>.");'
|
||||
- text: '<code>myArray</code> ينبغي أن تساوي <code>[9,7,5,3,1]</code> .'
|
||||
testString: 'assert.deepEqual(myArray, [9,7,5,3,1], "<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = [];
|
||||
|
||||
for (var i = 10; i > 0; i -= 2) {
|
||||
ourArray.push(i);
|
||||
}
|
||||
|
||||
// Setup
|
||||
var myArray = [];
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: 565bbe00e9cc8ac0725390f4
|
||||
title: Counting Cards
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: عد بطاقات
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في لعبة الكازينو Blackjack ، يمكن للاعب الحصول على ميزة على المنزل من خلال تتبع العدد النسبي للبطاقات العالية والمنخفضة المتبقية في سطح السفينة. وهذا ما يسمى <a href="https://en.wikipedia.org/wiki/Card_counting" target="_blank">حساب البطاقة</a> . وجود المزيد من البطاقات العالية المتبقية في سطح السفينة تفضل اللاعب. يتم تعيين قيمة لكل بطاقة وفقًا للجدول أدناه. عندما يكون العد موجبًا ، يجب أن يراهن اللاعب عالياً. عندما يكون العدد صفرًا أو سلبيًا ، يجب على اللاعب الرهان منخفضًا. <table class="table table-striped" style=";text-align:right;direction:rtl"><thead><tr><th> عد التغيير </th><th> بطاقات </th></tr></thead><tbody><tr><td> +1 </td><td> 2 و 3 و 4 و 5 و 6 </td></tr><tr><td> 0 </td><td> 7 و 8 و 9 </td></tr><tr><td> -1 </td><td> 10 ، 'J' ، 'Q' ، 'K' ، 'A' </td></tr></tbody></table> ستكتب وظيفة حساب البطاقة. سيحصل على معلمة <code>card</code> ، والتي يمكن أن تكون رقمًا أو سلسلة ، وزيادة أو إنقاص متغير <code>count</code> العالمي وفقًا لقيمة البطاقة (انظر الجدول). ستقوم الدالة بعد ذلك بإرجاع سلسلة مع العدد الحالي وسلسلة <code>Bet</code> إذا كان العدد موجبًا ، أو <code>Hold</code> إذا كان العدد صفراً أو سالباً. يجب فصل العدد الحالي وقرار اللاعب ( <code>Bet</code> أو <code>Hold</code> ) بمسافة واحدة. <strong>ناتج المثال</strong> <br> <code>-3 Hold</code> <br> <code>5 Bet</code> <strong>تلميح</strong> <code>5 Bet</code> <br> لا تقم بإعادة تعيين <code>count</code> إلى 0 عندما تكون القيمة 7 أو 8 أو 9. <br> لا ترجع مصفوفة. <br> لا تقم بتضمين علامات الاقتباس (مفردة أو مزدوجة) في الإخراج. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions">
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تعود تسلسلات البطاقات 2 و 3 و 4 و 5 و 6 إلى <code>5 Bet</code>
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })(), "Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>");'
|
||||
- text: يجب أن تعود تسلسلات البطاقات 7 و 8 و 9 <code>0 Hold</code>
|
||||
testString: 'assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })(), "Cards Sequence 7, 8, 9 should return <code>0 Hold</code>");'
|
||||
- text: يجب أن تعود تسلسلات البطاقات 10 و J و Q و K و A إلى <code>-5 Hold</code>
|
||||
testString: 'assert((function(){ count = 0; cc(10);cc("J");cc("Q");cc("K");var out = cc("A"); if(out === "-5 Hold") {return true;} return false; })(), "Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>");'
|
||||
- text: يجب أن تعود تسلسلات البطاقات 3 و 7 و Q و 8 و A إلى <code>-1 Hold</code>
|
||||
testString: 'assert((function(){ count = 0; cc(3);cc(7);cc("Q");cc(8);var out = cc("A"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>");'
|
||||
- text: يجب أن تعيد بطاقات التسلسل 2 ، J ، 9 ، 2 ، 7 <code>1 Bet</code>
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc("J");cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>");'
|
||||
- text: يجب أن تعيد بطاقات التسلسل 2 و 2 و 10 <code>1 Bet</code>
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, 2, 10 should return <code>1 Bet</code>");'
|
||||
- text: يجب أن تعود تسلسلات البطاقات 3 ، 2 ، A ، 10 ، K <code>-1 Hold</code>
|
||||
testString: 'assert((function(){ count = 0; cc(3);cc(2);cc("A");cc(10);var out = cc("K"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var count = 0;
|
||||
|
||||
function cc(card) {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
return "Change Me";
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
// Add/remove calls to test your function.
|
||||
// Note: Only the last will display
|
||||
cc(2); cc(3); cc(7); cc('K'); cc('A');
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: cf1391c1c11feddfaeb4bdef
|
||||
title: Create Decimal Numbers with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: قم بإنشاء أرقام عشرية باستخدام جافا سكريبت
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكننا تخزين الأرقام العشرية في المتغيرات أيضًا. ويشار إلى الأرقام العشرية في بعض الأحيان باسم أرقام <dfn>النقطة العائمة</dfn> أو <dfn>العوامات</dfn> . <strong>ملحوظة</strong> <br> لا يمكن تمثيل جميع الأرقام الحقيقية بدقة في <dfn>نقطة عائمة</dfn> . هذا يمكن أن يؤدي إلى أخطاء التقريب. <a href="https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems" target="_blank">التفاصيل هنا</a> . </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إنشاء متغير <code>myDecimal</code> وإعطائه قيمة عشرية مع جزء كسري (على سبيل المثال <code>5.7</code> ). </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون <code>myDecimal</code> رقمًا.
|
||||
testString: 'assert(typeof myDecimal === "number", "<code>myDecimal</code> should be a number.");'
|
||||
- text: <code>myDecimal</code> يجب أن يكون لديك <code>myDecimal</code> العشرية
|
||||
testString: 'assert(myDecimal % 1 != 0, "<code>myDecimal</code> should have a decimal point"); '
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var ourDecimal = 5.7;
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,60 @@
|
||||
---
|
||||
id: bd7123c9c443eddfaeb5bdef
|
||||
title: Declare JavaScript Variables
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: تحديد متغيرات جافا سكريبت
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في علم الكمبيوتر ، <dfn>البيانات</dfn> هي أي شيء مفيد للكمبيوتر. يوفر JavaScript سبعة <dfn>أنواع بيانات</dfn> مختلفة <code>undefined</code> ، <code>null</code> ، <code>boolean</code> ، <code>string</code> ، <code>symbol</code> ، <code>number</code> ، <code>object</code> . على سبيل المثال ، تميز أجهزة الكمبيوتر بين الأرقام ، مثل الرقم <code>12</code> ، <code>strings</code> ، مثل <code>"12"</code> أو <code>"dog"</code> أو <code>"123 cats"</code> ، وهي مجموعات من الأحرف. يمكن لأجهزة الكمبيوتر إجراء العمليات الحسابية على عدد ، ولكن ليس على سلسلة. تسمح <dfn>المتغيرات</dfn> لأجهزة الكمبيوتر بتخزين البيانات ومعالجتها بطريقة ديناميكية. يفعلون ذلك باستخدام "تسمية" للإشارة إلى البيانات بدلاً من استخدام البيانات نفسها. يمكن تخزين أي من أنواع البيانات السبعة في متغير. تشبه <code>Variables</code> x و y التي تستخدمها في الرياضيات ، مما يعني أنها اسم بسيط لتمثيل البيانات التي نريد الرجوع إليها. تختلف <code>variables</code> الكمبيوتر عن <code>variables</code> الرياضية في أنها يمكن أن تخزن قيمًا مختلفة في أوقات مختلفة. نقول جافا سكريبت لإنشاء أو <dfn>تعريف</dfn> متغير عن طريق وضع الكلمة <code>var</code> أمامه، كما يلي: <blockquote style=";text-align:right;direction:rtl"> var ourName؛ </blockquote> يخلق <code>variable</code> يسمى <code>ourName</code> . في جافا سكريبت ، ننتهي من العبارات بفواصل منقوطة. يمكن أن تتكون أسماء <code>Variable</code> من أرقام وأحرف و <code>$</code> أو <code>_</code> ، لكن قد لا تحتوي على مسافات أو تبدأ برقم. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استخدم الكلمة الأساسية <code>var</code> لإنشاء متغير يسمى <code>myName</code> . <strong>ملحوظة</strong> <br> انظر إلى مثال <code>ourName</code> إذا واجهتك <code>ourName</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تعلن <code>myName</code> مع الكلمة الرئيسية <code>var</code> ، وتنتهي بفاصلة منقوطة
|
||||
testString: 'assert(/var\s+myName\s*;/.test(code), "You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourName;
|
||||
|
||||
// Declare myName below this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: bd7123c9c444eddfaeb5bdef
|
||||
title: Declare String Variables
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: تعبير سلسلة المتغيرات
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> سبق لنا استخدام الرمز <code>var myName = "your name";</code> يسمى <code>"your name"</code> <dfn>سلسلة</dfn> <dfn>حرفية</dfn> . وهي سلسلة لأنها عبارة عن سلسلة من صفر أو أكثر من الأحرف محاطة بعلامات اقتباس مفردة أو مزدوجة. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إنشاء اثنين الجديدة <code>string</code> المتغيرات: <code>myFirstName</code> و <code>myLastName</code> وتعيينها القيم من الاسم الأول والأخير، على التوالي. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون <code>myFirstName</code> عبارة عن سلسلة بها حرف واحد على الأقل.
|
||||
testString: 'assert((function(){if(typeof myFirstName !== "undefined" && typeof myFirstName === "string" && myFirstName.length > 0){return true;}else{return false;}})(), "<code>myFirstName</code> should be a string with at least one character in it.");'
|
||||
- text: يجب أن يكون <code>myLastName</code> عبارة عن سلسلة بها حرف واحد على الأقل.
|
||||
testString: 'assert((function(){if(typeof myLastName !== "undefined" && typeof myLastName === "string" && myLastName.length > 0){return true;}else{return false;}})(), "<code>myLastName</code> should be a string with at least one character in it.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var firstName = "Alan";
|
||||
var lastName = "Turing";
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ad
|
||||
title: Decrement a Number with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: إنقاص رقم مع JavaScript
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكنك بسهولة <dfn>إنقاص</dfn> أو إنقاص متغير بواحد مع <code>--</code> المشغل. <code>i--;</code> يعادل <code>i = i - 1;</code> <strong>ملحوظة</strong> <br> يصبح الخط بأكمله <code>i--;</code> ، مما يلغي الحاجة إلى علامة المساواة. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> تغيير الرمز لاستخدام <code>--</code> المشغل على <code>myVar</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يساوي <code>myVar</code> <code>10</code>
|
||||
testString: 'assert(myVar === 10, "<code>myVar</code> should equal <code>10</code>");'
|
||||
- text: <code>myVar = myVar - 1;</code> يجب تغييرها
|
||||
testString: 'assert(/var\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code), "<code>myVar = myVar - 1;</code> should be changed");'
|
||||
- text: استخدم <code>--</code> المشغل على <code>myVar</code>
|
||||
testString: 'assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code), "Use the <code>--</code> operator on <code>myVar</code>");'
|
||||
- text: لا تغير الكود فوق الخط
|
||||
testString: 'assert(/var myVar = 11;/.test(code), "Do not change code above the line");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var myVar = 11;
|
||||
|
||||
// Only change code below this line
|
||||
myVar = myVar - 1;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392d3
|
||||
title: Delete Properties from a JavaScript Object
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: حذف الخصائص من كائن JavaScript
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكننا أيضًا حذف خصائص من كائنات مثل: <code>delete ourDog.bark;</code> </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> حذف خاصية <code>"tails"</code> من <code>myDog</code> . يمكنك استخدام أي نقطة أو تدوين قوس. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: حذف الخاصية <code>"tails"</code> من <code>myDog</code> .
|
||||
testString: 'assert(typeof myDog === "object" && myDog.tails === undefined, "Delete the property <code>"tails"</code> from <code>myDog</code>.");'
|
||||
- text: لا تقم بتعديل إعداد <code>myDog</code>
|
||||
testString: 'assert(code.match(/"tails": 1/g).length > 1, "Do not modify the <code>myDog</code> setup");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourDog = {
|
||||
"name": "Camper",
|
||||
"legs": 4,
|
||||
"tails": 1,
|
||||
"friends": ["everything!"],
|
||||
"bark": "bow-wow"
|
||||
};
|
||||
|
||||
delete ourDog.bark;
|
||||
|
||||
// Setup
|
||||
var myDog = {
|
||||
"name": "Happy Coder",
|
||||
"legs": 4,
|
||||
"tails": 1,
|
||||
"friends": ["freeCodeCamp Campers"],
|
||||
"bark": "woof"
|
||||
};
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: bd7993c9ca9feddfaeb7bdef
|
||||
title: Divide One Decimal by Another with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: قسّم رقم عشري واحد إلى آخر باستخدام جافا سكريبت
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> الآن دعونا تقسيم واحد عشري بآخر. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> غيِّر القيمة <code>0.0</code> بحيث يساوي ذلك <code>quotient</code> <code>2.2</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يساوي <code>quotient</code> المتغير <code>2.2</code>
|
||||
testString: 'assert(quotient === 2.2, "The variable <code>quotient</code> should equal <code>2.2</code>");'
|
||||
- text: يجب عليك استخدام <code>/</code> المشغل لتقسيم 4.4 على 2
|
||||
testString: 'assert(/4\.40*\s*\/\s*2\.*0*/.test(code), "You should use the <code>/</code> operator to divide 4.4 by 2");'
|
||||
- text: يجب تعيين متغير القسمة مرة واحدة فقط
|
||||
testString: 'assert(code.match(/quotient/g).length === 1, "The quotient variable should only be assigned once");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var quotient = 0.0 / 2.0; // Fix this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,59 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb6bdef
|
||||
title: Divide One Number by Another with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: قسمة رقم واحد على آخر باستخدام JavaScript
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكننا أيضًا تقسيم رقم واحد بآخر. تستخدم جافا سكريبت الرمز <code>/</code> للقسمة. <p style=";text-align:right;direction:rtl"> <strong>مثال</strong> </p><blockquote style=";text-align:right;direction:rtl"> myVar = 16/2؛ // تعيين 8 </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> تغيير <code>0</code> بحيث يكون <code>quotient</code> تساوي <code>2</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: اجعل <code>quotient</code> المتغير تساوي 2.
|
||||
testString: 'assert(quotient === 2, "Make the variable <code>quotient</code> equal to 2.");'
|
||||
- text: استخدم <code>/</code> المشغل
|
||||
testString: 'assert(/\d+\s*\/\s*\d+/.test(code), "Use the <code>/</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var quotient = 66 / 0;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b6
|
||||
title: Escape Sequences in Strings
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: الهروب من التسلسل في السلاسل
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> لا تكون علامات الاقتباس هي الأحرف الوحيدة التي يمكن <dfn>تجنبها</dfn> داخل سلسلة. هناك سببان لاستخدام أحرف الهروب: أولاً هو السماح لك باستخدام الأحرف التي قد لا تتمكن من كتابتها ، مثل backspace. ثانيًا ، تسمح لك بتمثيل علامات الاقتباس المتعددة في سلسلة بدون إساءة تفسير جافا سكريبت لما تعنيه. تعلمنا هذا في التحدي السابق. <table class="table table-striped" style=";text-align:right;direction:rtl"><thead><tr><th> الشفرة </th><th> انتاج | </th></tr></thead><tbody><tr><td> <code>\'</code> </td> <td> اقتباس واحد </td></tr><tr><td> <code>\"</code> </td> <td> اقتباس مزدوج </td></tr><tr><td> <code>\\</code> </td> <td> مائل </td></tr><tr><td> <code>\n</code> </td> <td> خط جديد </td></tr><tr><td> <code>\r</code> </td> <td> إرجاع </td></tr><tr><td> <code>\t</code> </td> <td> التبويب </td></tr><tr><td> <code>\b</code> </td> <td> مسافة للخلف </td></tr><tr><td> <code>\f</code> </td> <td> نموذج تغذية </td></tr></tbody></table> <em>لاحظ أنه يجب أن يتم إبطال الخط المائل العكسي نفسه ليتم عرضه كشرطة مائلة للخلف (Backslash).</em> </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بتعيين أسطر النص الثلاثة التالية في <code>myStr</code> متغير واحد باستخدام تسلسلات الهروب. <blockquote style=";text-align:right;direction:rtl"> السطر الأول <br> \السطر الثاني <br> ThirdLine </blockquote> ستحتاج إلى استخدام تسلسلات الهروب لإدراج أحرف خاصة بشكل صحيح. ستحتاج أيضًا إلى اتباع التباعد كما يبدو أعلاه ، مع عدم وجود مسافات بين تتابعات الهروب أو الكلمات. هنا هو النص مع تسلسل الهروب مكتوبة. <q>FirstLine <code>newline</code> <code>tab</code> <code>backslash</code> SecondLine <code>newline</code> ThirdLine</q> </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب ألا تحتوي <code>myStr</code> على أية مسافات
|
||||
testString: 'assert(!/ /.test(myStr), "<code>myStr</code> should not contain any spaces");'
|
||||
- text: يجب أن تحتوي <code>myStr</code> على السلاسل <code>FirstLine</code> و <code>SecondLine</code> و <code>ThirdLine</code> (تذكر حالة الحساسية)
|
||||
testString: 'assert(/FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr), "<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)");'
|
||||
- text: يجب أن يتبع <code>FirstLine</code> حرف السطر الجديد <code>\n</code>
|
||||
testString: 'assert(/FirstLine\n/.test(myStr), "<code>FirstLine</code> should be followed by the newline character <code>\n</code>");'
|
||||
- text: يجب أن تحتوي <code>myStr</code> على حرف tab <code>\t</code> يتبع حرف السطر الجديد
|
||||
testString: 'assert(/\n\t/.test(myStr), "<code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character");'
|
||||
- text: <code>SecondLine</code> يجب أن يسبقه حرف مائل <code>\\</code>
|
||||
testString: 'assert(/\SecondLine/.test(myStr), "<code>SecondLine</code> should be preceded by the backslash character <code>\\</code>");'
|
||||
- text: يجب أن يكون هناك حرف سطر جديد بين <code>SecondLine</code> و <code>ThirdLine</code>
|
||||
testString: 'assert(/SecondLine\nThirdLine/.test(myStr), "There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var myStr; // Change this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,59 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b5
|
||||
title: Escaping Literal Quotes in Strings
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: الهروب من الأسعار الحرفيه في الاوتار
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> عندما تقوم بتحديد سلسلة ، يجب أن تبدأ وتنتهي بعلامة اقتباس مفردة أو مزدوجة. ماذا يحدث عندما تحتاج إلى عرض سعر حرفي: <code>"</code> أو <code>'</code> داخل السلسلة الخاصة بك؟ في JavaScript ، يمكنك <dfn>الهروب</dfn> من اقتباس من اعتباره كنهاية لسلسلة الاقتباس عن طريق وضع خط <dfn>مائل عكسي</dfn> ( <code>\</code> ) أمام الاقتباس. <code>var sampleStr = "Alan said, \"Peter is learning JavaScript\".";</code> يشير هذا إلى جافا سكريبت بأن الاقتباس التالي ليس نهاية السلسلة ، بل يجب أن يظهر داخل السلسلة بدلاً من ذلك. لذلك إذا كنت ستطبعه إلى وحدة التحكم ، ستحصل على: <code>Alan said, "Peter is learning JavaScript".</code> </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استخدم <code>myStr</code> <dfn>المائلة العكسية</dfn> لتعيين سلسلة إلى متغير <code>myStr</code> بحيث إذا كنت <code>myStr</code> إلى وحدة التحكم ، سترى: <code>I am a "double quoted" string inside "double quotes".</code> </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب عليك استخدام علامتي اقتباس مزدوجتين ( <code>"</code> ) وأربعة علامات اقتباس مزدوجة ( <code>\"</code> ).
|
||||
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, "You should use two double quotes (<code>"</code>) and four escaped double quotes (<code>\"</code>).");'
|
||||
- text: 'يجب أن يحتوي myStr المتغير على السلسلة: <code>I am a "double quoted" string inside "double quotes".</code>'
|
||||
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", "Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var myStr = ""; // Change this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: bd7123c9c448eddfaeb5bdef
|
||||
title: Find the Length of a String
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: العثور على طول سلسلة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكنك العثور على طول قيمة <code>String</code> بالكتابة. <code>.length</code> بعد متغير السلسلة أو سلسلة حرفية. <code>"Alan Peter".length; // 10</code> على سبيل المثال ، إذا أنشأنا متغير <code>var firstName = "Charles"</code> ، يمكننا معرفة طول السلسلة <code>"Charles"</code> باستخدام الخاصية <code>firstName.length</code> . </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استخدم خاصية <code>.length</code> لحساب عدد الأحرف في متغير <code>lastName</code> وتعيينه إلى <code>lastNameLength</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تساوي <code>lastNameLength</code> ثمانية.
|
||||
testString: 'assert((function(){if(typeof lastNameLength !== "undefined" && typeof lastNameLength === "number" && lastNameLength === 8){return true;}else{return false;}})(), "<code>lastNameLength</code> should be equal to eight.");'
|
||||
- text: 'يجب أن تحصل على طول اسم <code>lastName</code> باستخدام <code>.length</code> مثل هذا: <code>lastName.length</code> .'
|
||||
testString: 'assert((function(){if(code.match(/\.length/gi) && code.match(/\.length/gi).length >= 2 && code.match(/var lastNameLength \= 0;/gi) && code.match(/var lastNameLength \= 0;/gi).length >= 1){return true;}else{return false;}})(), "You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var firstNameLength = 0;
|
||||
var firstName = "Ada";
|
||||
|
||||
firstNameLength = firstName.length;
|
||||
|
||||
// Setup
|
||||
var lastNameLength = 0;
|
||||
var lastName = "Lovelace";
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
lastNameLength = lastName;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ae
|
||||
title: Finding a Remainder in JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: العثور على البقية في جافا سكريبت
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يعطي عامل <dfn>الباقي</dfn> <code>%</code> الباقي من قسم رقمين. <strong>مثال</strong> <blockquote style=";text-align:right;direction:rtl"> 5٪ 2 = 1 بسبب <br> Math.floor (5/2) = 2 (Quotient) <br> 2 * 2 = 4 <br> 5 - 4 = 1 (البقية) </blockquote> <strong>استعمال</strong> <br> في الرياضيات ، يمكن التحقق من الرقم ليكون زوجي أو فردي عن طريق فحص الجزء المتبقي من تقسيم الرقم إلى <code>2</code> . <blockquote style=";text-align:right;direction:rtl"> 17٪ 2 = 1 (17 فردي) <br> 48٪ 2 = 0 (48 حتى) </blockquote> <strong>ملحوظة</strong> <br> في بعض الأحيان يشار إلى مشغل <dfn>الباقي</dfn> بشكل غير صحيح باسم مشغل "المعامل". وهي تشبه إلى حد بعيد المعامل ، ولكنها لا تعمل بشكل صحيح مع الأرقام السالبة. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> حدد <code>remainder</code> مساويًا لما تبقى من <code>11</code> مقسومًا على <code>3</code> باستخدام عامل <dfn>الباقي</dfn> ( <code>%</code> ). </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب تهيئة المتغير <code>remainder</code>
|
||||
testString: 'assert(/var\s+?remainder/.test(code), "The variable <code>remainder</code> should be initialized");'
|
||||
- text: يجب أن تكون قيمة <code>remainder</code> <code>2</code>
|
||||
testString: 'assert(remainder === 2, "The value of <code>remainder</code> should be <code>2</code>");'
|
||||
- text: يجب عليك استخدام عامل التشغيل <code>%</code>
|
||||
testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), "You should use the <code>%</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Only change code below this line
|
||||
|
||||
var remainder;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb9bdef
|
||||
title: Generate Random Fractions with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: توليد الكسور العشوائية مع جافا سكريبت
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> الأرقام العشوائية مفيدة لإنشاء سلوك عشوائي. يحتوي JavaScript على دالة <code>Math.random()</code> التي تنشئ رقمًا عشريًا عشوائيًا بين <code>0</code> (شامل) وليس تمامًا <code>1</code> (خاص). وبالتالي ، يمكن أن يقوم <code>Math.random()</code> بإرجاع <code>0</code> ولكن لا يُرجع أبدًا <strong>ملاحظة</strong> <code>1</code> <br> مثل <a href="storing-values-with-the-assignment-operator" target="_blank">تخزين القيم مع عامل التشغيل المتساوي</a> ، سيتم حل جميع استدعاءات الدوال قبل تنفيذ عملية <code>return</code> ، حتى نتمكن من <code>return</code> قيمة الدالة <code>Math.random()</code> . </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بتغيير <code>randomFraction</code> لإرجاع رقم عشوائي بدلاً من إرجاع <code>0</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>randomFraction</code> يجب إرجاع رقم عشوائي.
|
||||
testString: 'assert(typeof randomFraction() === "number", "<code>randomFraction</code> should return a random number.");'
|
||||
- text: يجب أن يكون الرقم الذي تم إرجاعه بواسطة <code>randomFraction</code> عشريًا.
|
||||
testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by <code>randomFraction</code> should be a decimal.");'
|
||||
- text: يجب أن تستخدم <code>Math.random</code> لإنشاء الرقم العشري العشوائي.
|
||||
testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using <code>Math.random</code> to generate the random decimal number.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function randomFraction() {
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
return 0;
|
||||
|
||||
// Only change code above this line.
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cf1111c1c12feddfaeb1bdef
|
||||
title: Generate Random Whole Numbers with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: توليد أرقام كاملة عشوائية مع جافا سكريبت
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> من الرائع أن نتمكن من توليد أرقام عشرية عشوائية ، ولكنها أكثر فائدة إذا استخدمناها لإنشاء أرقام صحيحة عشوائية. <ol style=";text-align:right;direction:rtl"><li style=";text-align:right;direction:rtl"> استخدم <code>Math.random()</code> لإنشاء عشري عشوائي. </li><li style=";text-align:right;direction:rtl"> اضرب هذا الرقم العشري العشوائي بـ <code>20</code> . </li><li style=";text-align:right;direction:rtl"> استخدم دالة أخرى ، <code>Math.floor()</code> الرقم إلى أقرب رقم <code>Math.floor()</code> له. </li></ol> تذكر أن <code>Math.random()</code> لا يمكنها أبدًا إرجاع <code>1</code> و ، نظرًا لأننا نقوم بالتقريب ، فمن المستحيل الحصول على <code>20</code> بالفعل. ستعطينا هذه التقنية عددًا صحيحًا بين <code>0</code> و <code>19</code> . وضع كل شيء معا ، وهذا هو ما تبدو عليه الكود لدينا: <code>Math.floor(Math.random() * 20);</code> نحن نطلق على <code>Math.random()</code> ، بضرب النتيجة بـ 20 ، ثم نمرر قيمة <code>Math.floor()</code> القيمة إلى أقرب رقم <code>Math.floor()</code> . </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استخدم هذه التقنية لتوليد وإرجاع رقم صحيح عشوائي بين <code>0</code> و <code>9</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تكون نتيجة <code>randomWholeNum</code> .
|
||||
testString: 'assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), "The result of <code>randomWholeNum</code> should be a whole number.");'
|
||||
- text: يجب أن تستخدم <code>Math.random</code> لإنشاء رقم عشوائي.
|
||||
testString: 'assert(code.match(/Math.random/g).length > 1, "You should be using <code>Math.random</code> to generate a random number.");'
|
||||
- text: يجب أن تضاعف نتيجة <code>Math.random</code> بمقدار 10 لجعله رقمًا بين صفر وتسعة.
|
||||
testString: 'assert(code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) || code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g), "You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.");'
|
||||
- text: يجب عليك استخدام <code>Math.floor</code> لإزالة الجزء العشري من الرقم.
|
||||
testString: 'assert(code.match(/Math.floor/g).length > 1, "You should use <code>Math.floor</code> to remove the decimal part of the number.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
|
||||
|
||||
function randomWholeNum() {
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
return Math.random();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: cf1111c1c12feddfaeb2bdef
|
||||
title: Generate Random Whole Numbers within a Range
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: توليد أرقام كاملة عشوائية داخل نطاق
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> بدلاً من إنشاء رقم عشوائي بين الصفر ورقم معين كما فعلنا من قبل ، يمكننا إنشاء رقم عشوائي يقع ضمن نطاق من رقمين محددين. للقيام بذلك، ونحن سوف تحدد العدد الأدنى من <code>min</code> والحد الأقصى ل <code>max</code> . إليكم الصيغة التي سنستخدمها. خذ لحظة في قراءته وحاول فهم ما يفعله هذا الكود: <code>Math.floor(Math.random() * (max - min + 1)) + min</code> </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم بإنشاء دالة تسمى <code>randomRange</code> والتي تأخذ نطاق <code>myMin</code> و <code>myMax</code> وتقوم بإرجاع رقم عشوائي أكبر من أو يساوي <code>myMin</code> ، وهو أقل من أو يساوي <code>myMax</code> ، شامل. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يكون العدد العشوائي الأدنى الذي يمكن إنشاؤه بواسطة <code>randomRange</code> مساوياً للحد الأدنى للرقم ، <code>myMin</code> .
|
||||
testString: 'assert(calcMin === 5, "The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.");'
|
||||
- text: يجب أن يكون الرقم العشوائي الأعلى الذي يمكن إنشاؤه بواسطة <code>randomRange</code> مساويا <code>myMax</code> عدد ممكن ، <code>myMax</code> .
|
||||
testString: 'assert(calcMax === 15, "The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.");'
|
||||
- text: يجب أن يكون الرقم العشوائي الذي تم إنشاؤه بواسطة <code>randomRange</code> عددًا صحيحًا وليس عشريًا.
|
||||
testString: 'assert(randomRange(0,1) % 1 === 0 , "The random number generated by <code>randomRange</code> should be an integer, not a decimal.");'
|
||||
- text: <code>randomRange</code> يجب استخدام كل <code>myMax</code> و <code>myMin</code> ، وإرجاع رقم عشوائي في النطاق الخاص بك.
|
||||
testString: 'assert((function(){if(code.match(/myMax/g).length > 1 && code.match(/myMin/g).length > 2 && code.match(/Math.floor/g) && code.match(/Math.random/g)){return true;}else{return false;}})(), "<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
function ourRandomRange(ourMin, ourMax) {
|
||||
|
||||
return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
|
||||
}
|
||||
|
||||
ourRandomRange(1, 9);
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
function randomRange(myMin, myMax) {
|
||||
|
||||
return 0; // Change this line
|
||||
|
||||
}
|
||||
|
||||
// Change these values to test your function
|
||||
var myRandom = randomRange(5, 15);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,109 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244be
|
||||
title: Global Scope and Functions
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: النطاق العالمي والوظائف
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في JavaScript ، يشير <dfn>النطاق</dfn> إلى رؤية المتغيرات. المتغيرات التي يتم تعريفها خارج كتلة وظيفة لها نطاق <dfn>عالمي</dfn> . وهذا يعني أنه يمكن رؤيتها في أي مكان في شفرة جافا سكريبت. يتم إنشاء المتغيرات التي يتم استخدامها بدون الكلمة الأساسية <code>var</code> تلقائيًا في النطاق <code>global</code> . هذا يمكن أن يخلق عواقب غير مقصودة في مكان آخر في التعليمات البرمجية الخاصة بك أو عند تشغيل وظيفة مرة أخرى. يجب عليك دائما أن تعلن عن المتغيرات الخاصة بك مع <code>var</code> . </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> باستخدام <code>var</code> ، قم بتعريف متغير <code>global</code> <code>myGlobal</code> خارج أي وظيفة. قم بتهيئته بقيمة <code>10</code> . داخل الدالة <code>fun1</code> ، قم بتعيين <code>5</code> إلى <code>oopsGlobal</code> <strong><em>دون</em></strong> استخدام الكلمة الأساسية <code>var</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب تعريف <code>myGlobal</code>
|
||||
testString: 'assert(typeof myGlobal != "undefined", "<code>myGlobal</code> should be defined");'
|
||||
- text: يجب أن يكون ل <code>myGlobal</code> قيمة <code>10</code>
|
||||
testString: 'assert(myGlobal === 10, "<code>myGlobal</code> should have a value of <code>10</code>");'
|
||||
- text: يجب إعلان <code>myGlobal</code> باستخدام الكلمة الرئيسية <code>var</code>
|
||||
testString: 'assert(/var\s+myGlobal/.test(code), "<code>myGlobal</code> should be declared using the <code>var</code> keyword");'
|
||||
- text: يجب أن يكون <code>oopsGlobal</code> متغيرًا عامًا وله قيمة <code>5</code>
|
||||
testString: 'assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5, "<code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Declare your variable here
|
||||
|
||||
|
||||
function fun1() {
|
||||
// Assign 5 to oopsGlobal Here
|
||||
|
||||
}
|
||||
|
||||
// Only change code above this line
|
||||
function fun2() {
|
||||
var output = "";
|
||||
if (typeof myGlobal != "undefined") {
|
||||
output += "myGlobal: " + myGlobal;
|
||||
}
|
||||
if (typeof oopsGlobal != "undefined") {
|
||||
output += " oopsGlobal: " + oopsGlobal;
|
||||
}
|
||||
console.log(output);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### Before Test
|
||||
<div id='js-setup'>
|
||||
|
||||
```js
|
||||
var logOutput = "";
|
||||
var originalConsole = console
|
||||
function capture() {
|
||||
var nativeLog = console.log;
|
||||
console.log = function (message) {
|
||||
logOutput = message;
|
||||
if(nativeLog.apply) {
|
||||
nativeLog.apply(originalConsole, arguments);
|
||||
} else {
|
||||
var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
|
||||
nativeLog(nativeMsg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function uncapture() {
|
||||
console.log = originalConsole.log;
|
||||
}
|
||||
var oopsGlobal;
|
||||
capture();
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c0
|
||||
title: Global vs. Local Scope in Functions
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: نطاق عالمي مقابل نطاق محلي في الوظائف
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> من الممكن أن يكون لديك متغيرات <dfn>محلية</dfn> <dfn>وعالمية</dfn> تحمل نفس الاسم. عند القيام بذلك ، يأخذ المتغير <code>local</code> الأسبقية على المتغير <code>global</code> . في هذا المثال: <blockquote style=";text-align:right;direction:rtl"> var someVar = "Hat" ، <br> وظيفة myFun () { <br> var someVar = "الرأس" ؛ <br> عودة بعض <br> } </blockquote> ستقوم الدالة <code>myFun</code> بإرجاع <code>"Head"</code> لأن الإصدار <code>local</code> للمتغير موجود. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة متغير محلي لوظيفة <code>myOutfit</code> لتجاوز قيمة <code>outerWear</code> مع <code>"sweater"</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: لا تغير قيمة <code>outerWear</code>
|
||||
testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global <code>outerWear</code>");'
|
||||
- text: يجب أن يعود <code>myOutfit</code> <code>"sweater"</code>
|
||||
testString: 'assert(myOutfit() === "sweater", "<code>myOutfit</code> should return <code>"sweater"</code>");'
|
||||
- text: لا تقم بتغيير بيان الإرجاع
|
||||
testString: 'assert(/return outerWear/.test(code), "Do not change the return statement");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var outerWear = "T-Shirt";
|
||||
|
||||
function myOutfit() {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return outerWear;
|
||||
}
|
||||
|
||||
myOutfit();
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: 5664820f61c48e80c9fa476c
|
||||
title: Golf Code
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(4, 1) === "Hole-in-one!", "<code>golfScore(4, 1)</code> should return "Hole-in-one!"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(4, 2) === "Eagle", "<code>golfScore(4, 2)</code> should return "Eagle"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(5, 2) === "Eagle", "<code>golfScore(5, 2)</code> should return "Eagle"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(4, 3) === "Birdie", "<code>golfScore(4, 3)</code> should return "Birdie"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(4, 4) === "Par", "<code>golfScore(4, 4)</code> should return "Par"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(1, 1) === "Hole-in-one!", "<code>golfScore(1, 1)</code> should return "Hole-in-one!"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(5, 5) === "Par", "<code>golfScore(5, 5)</code> should return "Par"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(4, 5) === "Bogey", "<code>golfScore(4, 5)</code> should return "Bogey"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(4, 6) === "Double Bogey", "<code>golfScore(4, 6)</code> should return "Double Bogey"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(4, 7) === "Go Home!", "<code>golfScore(4, 7)</code> should return "Go Home!"");'
|
||||
- text: ''
|
||||
testString: 'assert(golfScore(5, 9) === "Go Home!", "<code>golfScore(5, 9)</code> should return "Go Home!"");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
|
||||
function golfScore(par, strokes) {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
return "Change Me";
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
// Change these values to test
|
||||
golfScore(5, 4);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ac
|
||||
title: Increment a Number with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(myVar === 88, "<code>myVar</code> should equal <code>88</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2});/.test(code), "<code>myVar = myVar + 1;</code> should be changed");'
|
||||
- text: ''
|
||||
testString: 'assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code), "Use the <code>++</code> operator");'
|
||||
- text: ''
|
||||
testString: 'assert(/var myVar = 87;/.test(code), "Do not change code above the line");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var myVar = 87;
|
||||
|
||||
// Only change code below this line
|
||||
myVar = myVar + 1;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,60 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244a9
|
||||
title: Initializing Variables with the Assignment Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(/var\s+a\s*=\s*9\s*/.test(code), "Initialize <code>a</code> to a value of <code>9</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourVar = 19;
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244db
|
||||
title: Introducing Else If Statements
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/else/g).length > 1, "You should have at least two <code>else</code> statements");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/if/g).length > 1, "You should have at least two <code>if</code> statements");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/), "You should have closing and opening curly braces for each condition in your if else statement");'
|
||||
- text: ''
|
||||
testString: 'assert(testElseIf(0) === "Smaller than 5", "<code>testElseIf(0)</code> should return "Smaller than 5"");'
|
||||
- text: ''
|
||||
testString: 'assert(testElseIf(5) === "Between 5 and 10", "<code>testElseIf(5)</code> should return "Between 5 and 10"");'
|
||||
- text: ''
|
||||
testString: 'assert(testElseIf(7) === "Between 5 and 10", "<code>testElseIf(7)</code> should return "Between 5 and 10"");'
|
||||
- text: ''
|
||||
testString: 'assert(testElseIf(10) === "Between 5 and 10", "<code>testElseIf(10)</code> should return "Between 5 and 10"");'
|
||||
- text: ''
|
||||
testString: 'assert(testElseIf(12) === "Greater than 10", "<code>testElseIf(12)</code> should return "Greater than 10"");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testElseIf(val) {
|
||||
if (val > 10) {
|
||||
return "Greater than 10";
|
||||
}
|
||||
|
||||
if (val < 5) {
|
||||
return "Smaller than 5";
|
||||
}
|
||||
|
||||
return "Between 5 and 10";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testElseIf(7);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244da
|
||||
title: Introducing Else Statements
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement in the editor");'
|
||||
- text: ''
|
||||
testString: 'assert(/else/g.test(code), "You should use an <code>else</code> statement");'
|
||||
- text: ''
|
||||
testString: 'assert(testElse(4) === "5 or Smaller", "<code>testElse(4)</code> should return "5 or Smaller"");'
|
||||
- text: ''
|
||||
testString: 'assert(testElse(5) === "5 or Smaller", "<code>testElse(5)</code> should return "5 or Smaller"");'
|
||||
- text: ''
|
||||
testString: 'assert(testElse(6) === "Bigger than 5", "<code>testElse(6)</code> should return "Bigger than 5"");'
|
||||
- text: ''
|
||||
testString: 'assert(testElse(10) === "Bigger than 5", "<code>testElse(10)</code> should return "Bigger than 5"");'
|
||||
- text: ''
|
||||
testString: 'assert(/var result = "";/.test(code) && /return result;/.test(code), "Do not change the code above or below the lines.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function testElse(val) {
|
||||
var result = "";
|
||||
// Only change code below this line
|
||||
|
||||
if (val > 5) {
|
||||
result = "Bigger than 5";
|
||||
}
|
||||
|
||||
if (val <= 5) {
|
||||
result = "5 or Smaller";
|
||||
}
|
||||
|
||||
// Only change code above this line
|
||||
return result;
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
testElse(4);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: 56104e9e514f539506016a5c
|
||||
title: Iterate Odd Numbers With a For Loop
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
- text: ''
|
||||
testString: 'assert.deepEqual(myArray, [1,3,5,7,9], "<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = [];
|
||||
|
||||
for (var i = 0; i < 10; i += 2) {
|
||||
ourArray.push(i);
|
||||
}
|
||||
|
||||
// Setup
|
||||
var myArray = [];
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: 5675e877dbd60be8ad28edc6
|
||||
title: Iterate Through an Array with a For Loop
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/var.*?total\s*=\s*0.*?;/), "<code>total</code> should be declared and initialized to 0");'
|
||||
- text: ''
|
||||
testString: 'assert(total === 20, "<code>total</code> should equal 20");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/), "You should use a <code>for</code> loop to iterate through <code>myArr</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(!code.match(/total[\s\+\-]*=\s*(\d(?!\s*[;,])|[1-9])/g), "Do not set <code>total</code> to 20 directly");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArr = [ 9, 10, 11, 12];
|
||||
var ourTotal = 0;
|
||||
|
||||
for (var i = 0; i < ourArr.length; i++) {
|
||||
ourTotal += ourArr[i];
|
||||
}
|
||||
|
||||
// Setup
|
||||
var myArr = [ 2, 3, 4, 5, 6];
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: 5a2efd662fb457916e1fe604
|
||||
title: Iterate with JavaScript Do...While Loops
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/do/g), "You should be using a <code>do...while</code> loop for this.");'
|
||||
- text: ''
|
||||
testString: 'assert.deepEqual(myArray, [10], "<code>myArray</code> should equal <code>[10]</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert.deepEqual(i, 11, "<code>i</code> should equal <code>11</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var myArray = [];
|
||||
var i = 10;
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
while (i < 5) {
|
||||
myArray.push(i);
|
||||
i++;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb5bdef
|
||||
title: Iterate with JavaScript For Loops
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
- text: ''
|
||||
testString: 'assert.deepEqual(myArray, [1,2,3,4,5], "<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = [];
|
||||
|
||||
for (var i = 0; i < 5; i++) {
|
||||
ourArray.push(i);
|
||||
}
|
||||
|
||||
// Setup
|
||||
var myArray = [];
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb1bdef
|
||||
title: Iterate with JavaScript While Loops
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/while/g), "You should be using a <code>while</code> loop for this.");'
|
||||
- text: ''
|
||||
testString: 'assert.deepEqual(myArray, [0,1,2,3,4], "<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var myArray = [];
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,96 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244bf
|
||||
title: Local Scope and Functions
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof myVar === "undefined", "No global <code>myVar</code> variable");'
|
||||
- text: ''
|
||||
testString: 'assert(/var\s+myVar/.test(code), "Add a local <code>myVar</code> variable");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function myLocalScope() {
|
||||
'use strict'; // you shouldn't need to edit this line
|
||||
|
||||
console.log(myVar);
|
||||
}
|
||||
myLocalScope();
|
||||
|
||||
// Run and check the console
|
||||
// myVar is not defined outside of myLocalScope
|
||||
console.log(myVar);
|
||||
|
||||
// Now remove the console log line to pass the test
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### Before Test
|
||||
<div id='js-setup'>
|
||||
|
||||
```js
|
||||
var logOutput = "";
|
||||
var originalConsole = console
|
||||
function capture() {
|
||||
var nativeLog = console.log;
|
||||
console.log = function (message) {
|
||||
logOutput = message;
|
||||
if(nativeLog.apply) {
|
||||
nativeLog.apply(originalConsole, arguments);
|
||||
} else {
|
||||
var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
|
||||
nativeLog(nativeMsg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function uncapture() {
|
||||
console.log = originalConsole.log;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: 5690307fddb111c6084545d7
|
||||
title: Logical Order in If Else Statements
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(orderMyLogic(4) === "Less than 5", "<code>orderMyLogic(4)</code> should return "Less than 5"");'
|
||||
- text: ''
|
||||
testString: 'assert(orderMyLogic(6) === "Less than 10", "<code>orderMyLogic(6)</code> should return "Less than 10"");'
|
||||
- text: ''
|
||||
testString: 'assert(orderMyLogic(11) === "Greater than or equal to 10", "<code>orderMyLogic(11)</code> should return "Greater than or equal to 10"");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function orderMyLogic(val) {
|
||||
if (val < 10) {
|
||||
return "Less than 10";
|
||||
} else if (val < 5) {
|
||||
return "Less than 5";
|
||||
} else {
|
||||
return "Greater than or equal to 10";
|
||||
}
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
orderMyLogic(7);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392cc
|
||||
title: Manipulate Arrays With pop()
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert((function(d){if(d[0][0] == "John" && d[0][1] === 23 && d[1] == undefined){return true;}else{return false;}})(myArray), "<code>myArray</code> should only contain <code>[["John", 23]]</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code), "Use <code>pop()</code> on <code>myArray</code>");'
|
||||
- text: ''
|
||||
testString: 'assert((function(d){if(d[0] == "cat" && d[1] === 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray), "<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = [1,2,3];
|
||||
var removedFromOurArray = ourArray.pop();
|
||||
// removedFromOurArray now equals 3, and ourArray now equals [1,2]
|
||||
|
||||
// Setup
|
||||
var myArray = [["John", 23], ["cat", 2]];
|
||||
|
||||
// Only change code below this line.
|
||||
var removedFromMyArray;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392cb
|
||||
title: Manipulate Arrays With push()
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert((function(d){if(d[2] != undefined && d[0][0] == "John" && d[0][1] === 23 && d[2][0] == "dog" && d[2][1] === 3 && d[2].length == 2){return true;}else{return false;}})(myArray), "<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = ["Stimpson", "J", "cat"];
|
||||
ourArray.push(["happy", "joy"]);
|
||||
// ourArray now equals ["Stimpson", "J", "cat", ["happy", "joy"]]
|
||||
|
||||
// Setup
|
||||
var myArray = [["John", 23], ["cat", 2]];
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392cd
|
||||
title: Manipulate Arrays With shift()
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert((function(d){if(d[0][0] == "dog" && d[0][1] === 3 && d[1] == undefined){return true;}else{return false;}})(myArray), "<code>myArray</code> should now equal <code>[["dog", 3]]</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert((function(d){if(d[0] == "John" && d[1] === 23 && typeof removedFromMyArray === "object"){return true;}else{return false;}})(removedFromMyArray), "<code>removedFromMyArray</code> should contain <code>["John", 23]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = ["Stimpson", "J", ["cat"]];
|
||||
var removedFromOurArray = ourArray.shift();
|
||||
// removedFromOurArray now equals "Stimpson" and ourArray now equals ["J", ["cat"]].
|
||||
|
||||
// Setup
|
||||
var myArray = [["John", 23], ["dog", 3]];
|
||||
|
||||
// Only change code below this line.
|
||||
var removedFromMyArray;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392ce
|
||||
title: Manipulate Arrays With unshift()
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert((function(d){if(typeof d[0] === "object" && d[0][0] == "Paul" && d[0][1] === 35 && d[1][0] != undefined && d[1][0] == "dog" && d[1][1] != undefined && d[1][1] == 3){return true;}else{return false;}})(myArray), "<code>myArray</code> should now have [["Paul", 35], ["dog", 3]].");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = ["Stimpson", "J", "cat"];
|
||||
ourArray.shift(); // ourArray now equals ["J", "cat"]
|
||||
ourArray.unshift("Happy");
|
||||
// ourArray now equals ["Happy", "J", "cat"]
|
||||
|
||||
// Setup
|
||||
var myArray = [["John", 23], ["dog", 3]];
|
||||
myArray.shift();
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244cb
|
||||
title: Manipulating Complex Objects
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(Array.isArray(myMusic), "<code>myMusic</code> should be an array");'
|
||||
- text: ''
|
||||
testString: 'assert(myMusic.length > 1, "<code>myMusic</code> should have at least two elements");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof myMusic[1] === "object", "<code>myMusic[1]</code> should be an object");'
|
||||
- text: ''
|
||||
testString: 'assert(Object.keys(myMusic[1]).length > 3, "<code>myMusic[1]</code> should have at least 4 properties");'
|
||||
- text: ''
|
||||
testString: 'assert(myMusic[1].hasOwnProperty("artist") && typeof myMusic[1].artist === "string", "<code>myMusic[1]</code> should contain an <code>artist</code> property which is a string");'
|
||||
- text: ''
|
||||
testString: 'assert(myMusic[1].hasOwnProperty("title") && typeof myMusic[1].title === "string", "<code>myMusic[1]</code> should contain a <code>title</code> property which is a string");'
|
||||
- text: ''
|
||||
testString: 'assert(myMusic[1].hasOwnProperty("release_year") && typeof myMusic[1].release_year === "number", "<code>myMusic[1]</code> should contain a <code>release_year</code> property which is a number");'
|
||||
- text: ''
|
||||
testString: 'assert(myMusic[1].hasOwnProperty("formats") && Array.isArray(myMusic[1].formats), "<code>myMusic[1]</code> should contain a <code>formats</code> property which is an array");'
|
||||
- text: ''
|
||||
testString: 'assert(myMusic[1].formats.every(function(item) { return (typeof item === "string")}) && myMusic[1].formats.length > 1, "<code>formats</code> should be an array of strings with at least two elements");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var myMusic = [
|
||||
{
|
||||
"artist": "Billy Joel",
|
||||
"title": "Piano Man",
|
||||
"release_year": 1973,
|
||||
"formats": [
|
||||
"CD",
|
||||
"8T",
|
||||
"LP"
|
||||
],
|
||||
"gold": true
|
||||
}
|
||||
// Add record here
|
||||
];
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb8bdef
|
||||
title: Modify Array Data With Indexes
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert((function(){if(typeof myArray != "undefined" && myArray[0] == 45 && myArray[1] == 64 && myArray[2] == 99){return true;}else{return false;}})(), "<code>myArray</code> should now be [45,64,99].");'
|
||||
- text: ''
|
||||
testString: 'assert((function(){if(code.match(/myArray\[0\]\s*=\s*/g)){return true;}else{return false;}})(), "You should be using correct index to modify the value in <code>myArray</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = [18,64,99];
|
||||
ourArray[1] = 45; // ourArray now equals [18,45,99].
|
||||
|
||||
// Setup
|
||||
var myArray = [18,64,99];
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244df
|
||||
title: Multiple Identical Options in Switch Statements
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(1) === "Low", "<code>sequentialSizes(1)</code> should return "Low"");'
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(2) === "Low", "<code>sequentialSizes(2)</code> should return "Low"");'
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(3) === "Low", "<code>sequentialSizes(3)</code> should return "Low"");'
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(4) === "Mid", "<code>sequentialSizes(4)</code> should return "Mid"");'
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(5) === "Mid", "<code>sequentialSizes(5)</code> should return "Mid"");'
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(6) === "Mid", "<code>sequentialSizes(6)</code> should return "Mid"");'
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(7) === "High", "<code>sequentialSizes(7)</code> should return "High"");'
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(8) === "High", "<code>sequentialSizes(8)</code> should return "High"");'
|
||||
- text: ''
|
||||
testString: 'assert(sequentialSizes(9) === "High", "<code>sequentialSizes(9)</code> should return "High"");'
|
||||
- text: ''
|
||||
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/case/g).length === 9, "You should have nine <code>case</code> statements");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function sequentialSizes(val) {
|
||||
var answer = "";
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return answer;
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
sequentialSizes(1);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,59 @@
|
||||
---
|
||||
id: bd7993c9c69feddfaeb7bdef
|
||||
title: Multiply Two Decimals with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(product === 5.0, "The variable <code>product</code> should equal <code>5.0</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert(/\*/.test(code), "You should use the <code>*</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var product = 2.0 * 0.0;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,59 @@
|
||||
---
|
||||
id: cf1231c1c11feddfaeb5bdef
|
||||
title: Multiply Two Numbers with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(product === 80,"Make the variable <code>product</code> equal 80");'
|
||||
- text: ''
|
||||
testString: 'assert(/\*/.test(code), "Use the <code>*</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var product = 8 * 0;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb7bdef
|
||||
title: Nest one Array within Another Array
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(Array.isArray(myArray) && myArray.some(Array.isArray), "<code>myArray</code> should have at least one array nested within another array.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = [["the universe", 42], ["everything", 101010]];
|
||||
|
||||
// Only change code below this line.
|
||||
var myArray = [];
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244e1
|
||||
title: Nesting For Loops
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(multiplyAll([[1],[2],[3]]) === 6, "<code>multiplyAll([[1],[2],[3]])</code> should return <code>6</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040, "<code>multiplyAll([[1,2],[3,4],[5,6,7]])</code> should return <code>5040</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54, "<code>multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])</code> should return <code>54</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function multiplyAll(arr) {
|
||||
var product = 1;
|
||||
// Only change code below this line
|
||||
|
||||
// Only change code above this line
|
||||
return product;
|
||||
}
|
||||
|
||||
// Modify values below to test your code
|
||||
multiplyAll([[1,2],[3,4],[5,6,7]]);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,97 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244bd
|
||||
title: Passing Values to Functions with Arguments
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof functionWithArgs === "function", "<code>functionWithArgs</code> should be a function");'
|
||||
- text: ''
|
||||
testString: 'if(typeof functionWithArgs === "function") { capture(); functionWithArgs(1,2); uncapture(); } assert(logOutput == 3, "<code>functionWithArgs(1,2)</code> should output <code>3</code>");'
|
||||
- text: ''
|
||||
testString: 'if(typeof functionWithArgs === "function") { capture(); functionWithArgs(7,9); uncapture(); } assert(logOutput == 16, "<code>functionWithArgs(7,9)</code> should output <code>16</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(/^\s*functionWithArgs\s*\(\s*\d+\s*,\s*\d+\s*\)\s*;/m.test(code), "Call <code>functionWithArgs</code> with two numbers after you define it.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
function ourFunctionWithArgs(a, b) {
|
||||
console.log(a - b);
|
||||
}
|
||||
ourFunctionWithArgs(10, 5); // Outputs 5
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### Before Test
|
||||
<div id='js-setup'>
|
||||
|
||||
```js
|
||||
var logOutput = "";
|
||||
var originalConsole = console
|
||||
function capture() {
|
||||
var nativeLog = console.log;
|
||||
console.log = function (message) {
|
||||
if(message) logOutput = JSON.stringify(message).trim();
|
||||
if(nativeLog.apply) {
|
||||
nativeLog.apply(originalConsole, arguments);
|
||||
} else {
|
||||
var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
|
||||
nativeLog(nativeMsg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function uncapture() {
|
||||
console.log = originalConsole.log;
|
||||
}
|
||||
|
||||
capture();
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: 599a789b454f2bbd91a3ff4d
|
||||
title: Practice comparing different values
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(compareEquality(10, "10") === "Not Equal", "<code>compareEquality(10, "10")</code> should return "Not Equal"");'
|
||||
- text: ''
|
||||
testString: 'assert(compareEquality("20", 20) === "Not Equal", "<code>compareEquality("20", 20)</code> should return "Not Equal"");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/===/g), "You should use the <code>===</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
function compareEquality(a, b) {
|
||||
if (a == b) { // Change this line
|
||||
return "Equal";
|
||||
}
|
||||
return "Not Equal";
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
compareEquality(10, "10");
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,95 @@
|
||||
---
|
||||
id: 5688e62ea601b2482ff8422b
|
||||
title: Profile Lookup
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(lookUpProfile("Kristian","lastName") === "Vos", "<code>"Kristian", "lastName"</code> should return <code>"Vos"</code>");'
|
||||
- text: ''
|
||||
testString: 'assert.deepEqual(lookUpProfile("Sherlock", "likes"), ["Intriguing Cases", "Violin"], "<code>"Sherlock", "likes"</code> should return <code>["Intriguing Cases", "Violin"]</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof lookUpProfile("Harry", "likes") === "object", "<code>"Harry","likes"</code> should return an array");'
|
||||
- text: ''
|
||||
testString: 'assert(lookUpProfile("Bob", "number") === "No such contact", "<code>"Bob", "number"</code> should return "No such contact"");'
|
||||
- text: ''
|
||||
testString: 'assert(lookUpProfile("Bob", "potato") === "No such contact", "<code>"Bob", "potato"</code> should return "No such contact"");'
|
||||
- text: ''
|
||||
testString: 'assert(lookUpProfile("Akira", "address") === "No such property", "<code>"Akira", "address"</code> should return "No such property"");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
//Setup
|
||||
var contacts = [
|
||||
{
|
||||
"firstName": "Akira",
|
||||
"lastName": "Laine",
|
||||
"number": "0543236543",
|
||||
"likes": ["Pizza", "Coding", "Brownie Points"]
|
||||
},
|
||||
{
|
||||
"firstName": "Harry",
|
||||
"lastName": "Potter",
|
||||
"number": "0994372684",
|
||||
"likes": ["Hogwarts", "Magic", "Hagrid"]
|
||||
},
|
||||
{
|
||||
"firstName": "Sherlock",
|
||||
"lastName": "Holmes",
|
||||
"number": "0487345643",
|
||||
"likes": ["Intriguing Cases", "Violin"]
|
||||
},
|
||||
{
|
||||
"firstName": "Kristian",
|
||||
"lastName": "Vos",
|
||||
"number": "unknown",
|
||||
"likes": ["JavaScript", "Gaming", "Foxes"]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
function lookUpProfile(name, prop){
|
||||
// Only change code below this line
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
// Change these values to test your function
|
||||
lookUpProfile("Akira", "likes");
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,59 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b4
|
||||
title: Quoting Strings with Single Quotes
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(!/\\/g.test(code) && myStr.match("\\s*<a href\\s*=\\s*"http://www.example.com"\\s*target\\s*=\\s*"_blank">\\s*Link\\s*</a>\\s*"), "Remove all the <code>backslashes</code> (<code>\</code>)");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/"/g).length === 4 && code.match(/"/g).length === 2, "You should have two single quotes <code>'</code> and four double quotes <code>"</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,106 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244cf
|
||||
title: Record Collection
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'collection = collectionCopy; assert(updateRecords(5439, "artist", "ABBA")[5439]["artist"] === "ABBA", "After <code>updateRecords(5439, "artist", "ABBA")</code>, <code>artist</code> should be <code>"ABBA"</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(updateRecords(5439, "tracks", "Take a Chance on Me")[5439]["tracks"].pop() === "Take a Chance on Me", "After <code>updateRecords(5439, "tracks", "Take a Chance on Me")</code>, <code>tracks</code> should have <code>"Take a Chance on Me"</code> as the last element.");'
|
||||
- text: ''
|
||||
testString: 'updateRecords(2548, "artist", ""); assert(!collection[2548].hasOwnProperty("artist"), "After <code>updateRecords(2548, "artist", "")</code>, <code>artist</code> should not be set");'
|
||||
- text: ''
|
||||
testString: 'assert(updateRecords(1245, "tracks", "Addicted to Love")[1245]["tracks"].pop() === "Addicted to Love", "After <code>updateRecords(1245, "tracks", "Addicted to Love")</code>, <code>tracks</code> should have <code>"Addicted to Love"</code> as the last element.");'
|
||||
- text: ''
|
||||
testString: 'assert(updateRecords(2468, "tracks", "Free")[2468]["tracks"][0] === "1999", "After <code>updateRecords(2468, "tracks", "Free")</code>, <code>tracks</code> should have <code>"1999"</code> as the first element.");'
|
||||
- text: ''
|
||||
testString: 'updateRecords(2548, "tracks", ""); assert(!collection[2548].hasOwnProperty("tracks"), "After <code>updateRecords(2548, "tracks", "")</code>, <code>tracks</code> should not be set");'
|
||||
- text: ''
|
||||
testString: 'assert(updateRecords(1245, "album", "Riptide")[1245]["album"] === "Riptide", "After <code>updateRecords(1245, "album", "Riptide")</code>, <code>album</code> should be <code>"Riptide"</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var collection = {
|
||||
"2548": {
|
||||
"album": "Slippery When Wet",
|
||||
"artist": "Bon Jovi",
|
||||
"tracks": [
|
||||
"Let It Rock",
|
||||
"You Give Love a Bad Name"
|
||||
]
|
||||
},
|
||||
"2468": {
|
||||
"album": "1999",
|
||||
"artist": "Prince",
|
||||
"tracks": [
|
||||
"1999",
|
||||
"Little Red Corvette"
|
||||
]
|
||||
},
|
||||
"1245": {
|
||||
"artist": "Robert Palmer",
|
||||
"tracks": [ ]
|
||||
},
|
||||
"5439": {
|
||||
"album": "ABBA Gold"
|
||||
}
|
||||
};
|
||||
// Keep a copy of the collection for tests
|
||||
var collectionCopy = JSON.parse(JSON.stringify(collection));
|
||||
|
||||
// Only change code below this line
|
||||
function updateRecords(id, prop, value) {
|
||||
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
// Alter values below to test your code
|
||||
updateRecords(5439, "artist", "ABBA");
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,88 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244e0
|
||||
title: Replacing If Else Chains with Switch
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(!/else/g.test(code), "You should not use any <code>else</code> statements anywhere in the editor");'
|
||||
- text: ''
|
||||
testString: 'assert(!/if/g.test(code), "You should not use any <code>if</code> statements anywhere in the editor");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/break/g).length >= 4, "You should have at least four <code>break</code> statements");'
|
||||
- text: ''
|
||||
testString: 'assert(chainToSwitch("bob") === "Marley", "<code>chainToSwitch("bob")</code> should be "Marley"");'
|
||||
- text: ''
|
||||
testString: 'assert(chainToSwitch(42) === "The Answer", "<code>chainToSwitch(42)</code> should be "The Answer"");'
|
||||
- text: ''
|
||||
testString: 'assert(chainToSwitch(1) === "There is no #1", "<code>chainToSwitch(1)</code> should be "There is no #1"");'
|
||||
- text: ''
|
||||
testString: 'assert(chainToSwitch(99) === "Missed me by this much!", "<code>chainToSwitch(99)</code> should be "Missed me by this much!"");'
|
||||
- text: ''
|
||||
testString: 'assert(chainToSwitch(7) === "Ate Nine", "<code>chainToSwitch(7)</code> should be "Ate Nine"");'
|
||||
- text: ''
|
||||
testString: 'assert(chainToSwitch("John") === "", "<code>chainToSwitch("John")</code> should be "" (empty string)");'
|
||||
- text: ''
|
||||
testString: 'assert(chainToSwitch(156) === "", "<code>chainToSwitch(156)</code> should be "" (empty string)");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function chainToSwitch(val) {
|
||||
var answer = "";
|
||||
// Only change code below this line
|
||||
|
||||
if (val === "bob") {
|
||||
answer = "Marley";
|
||||
} else if (val === 42) {
|
||||
answer = "The Answer";
|
||||
} else if (val === 1) {
|
||||
answer = "There is no #1";
|
||||
} else if (val === 99) {
|
||||
answer = "Missed me by this much!";
|
||||
} else if (val === 7) {
|
||||
answer = "Ate Nine";
|
||||
}
|
||||
|
||||
// Only change code above this line
|
||||
return answer;
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
chainToSwitch(7);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c2
|
||||
title: Return a Value from a Function with Return
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof timesFive === "function", "<code>timesFive</code> should be a function");'
|
||||
- text: ''
|
||||
testString: 'assert(timesFive(5) === 25, "<code>timesFive(5)</code> should return <code>25</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(timesFive(2) === 10, "<code>timesFive(2)</code> should return <code>10</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(timesFive(0) === 0, "<code>timesFive(0)</code> should return <code>0</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
function minusSeven(num) {
|
||||
return num - 7;
|
||||
}
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
console.log(minusSeven(10));
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c4
|
||||
title: Return Early Pattern for Functions
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof abTest(2,2) === "number" , "<code>abTest(2,2)</code> should return a number");'
|
||||
- text: ''
|
||||
testString: 'assert(abTest(2,2) === 8 , "<code>abTest(2,2)</code> should return <code>8</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(abTest(-2,2) === undefined , "<code>abTest(-2,2)</code> should return <code>undefined</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(abTest(2,-2) === undefined , "<code>abTest(2,-2)</code> should return <code>undefined</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(abTest(2,8) === 18 , "<code>abTest(2,8)</code> should return <code>18</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(abTest(3,3) === 12 , "<code>abTest(3,3)</code> should return <code>12</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
function abTest(a, b) {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
|
||||
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
|
||||
}
|
||||
|
||||
// Change values below to test your code
|
||||
abTest(2,2);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: 5679ceb97cbaa8c51670a16b
|
||||
title: Returning Boolean Values from Functions
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(isLess(10,15) === true, "<code>isLess(10,15)</code> should return <code>true</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(isLess(15, 10) === false, "<code>isLess(15,10)</code> should return <code>false</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(!/if|else/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function isLess(a, b) {
|
||||
// Fix this code
|
||||
if (a < b) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Change these values to test
|
||||
isLess(10, 15);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244dd
|
||||
title: Selecting from Many Options with Switch Statements
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(caseInSwitch(1) === "alpha", "<code>caseInSwitch(1)</code> should have a value of "alpha"");'
|
||||
- text: ''
|
||||
testString: 'assert(caseInSwitch(2) === "beta", "<code>caseInSwitch(2)</code> should have a value of "beta"");'
|
||||
- text: ''
|
||||
testString: 'assert(caseInSwitch(3) === "gamma", "<code>caseInSwitch(3)</code> should have a value of "gamma"");'
|
||||
- text: ''
|
||||
testString: 'assert(caseInSwitch(4) === "delta", "<code>caseInSwitch(4)</code> should have a value of "delta"");'
|
||||
- text: ''
|
||||
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function caseInSwitch(val) {
|
||||
var answer = "";
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return answer;
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
caseInSwitch(1);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244bc
|
||||
title: Shopping List
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(isArray, "<code>myList</code> should be an array");'
|
||||
- text: ''
|
||||
testString: 'assert(hasString, "The first elements in each of your sub-arrays must all be strings");'
|
||||
- text: ''
|
||||
testString: 'assert(hasNumber, "The second elements in each of your sub-arrays must all be numbers");'
|
||||
- text: ''
|
||||
testString: 'assert(count > 4, "You must have at least 5 items in your list");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var myList = [];
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,105 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c6
|
||||
title: Stand in Line
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert.isNumber(nextInLine([],5), "<code>nextInLine([], 5)</code> should return a number.");'
|
||||
- text: ''
|
||||
testString: 'assert(nextInLine([],1) === 1, "<code>nextInLine([], 1)</code> should return <code>1</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(nextInLine([2],1) === 2, "<code>nextInLine([2], 1)</code> should return <code>2</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(nextInLine([5,6,7,8,9],1) === 5, "<code>nextInLine([5,6,7,8,9], 1)</code> should return <code>5</code>");'
|
||||
- text: ''
|
||||
testString: 'nextInLine(testArr, 10); assert(testArr[4] === 10, "After <code>nextInLine(testArr, 10)</code>, <code>testArr[4]</code> should be <code>10</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function nextInLine(arr, item) {
|
||||
// Your code here
|
||||
|
||||
return item; // Change this line
|
||||
}
|
||||
|
||||
// Test Setup
|
||||
var testArr = [1,2,3,4,5];
|
||||
|
||||
// Display Code
|
||||
console.log("Before: " + JSON.stringify(testArr));
|
||||
console.log(nextInLine(testArr, 6)); // Modify this line to test
|
||||
console.log("After: " + JSON.stringify(testArr));
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### Before Test
|
||||
<div id='js-setup'>
|
||||
|
||||
```js
|
||||
var logOutput = [];
|
||||
var originalConsole = console
|
||||
function capture() {
|
||||
var nativeLog = console.log;
|
||||
console.log = function (message) {
|
||||
logOutput.push(message);
|
||||
if(nativeLog.apply) {
|
||||
nativeLog.apply(originalConsole, arguments);
|
||||
} else {
|
||||
var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
|
||||
nativeLog(nativeMsg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function uncapture() {
|
||||
console.log = originalConsole.log;
|
||||
}
|
||||
|
||||
capture();
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: bd7993c9c69feddfaeb8bdef
|
||||
title: Store Multiple Values in one Variable using JavaScript Arrays
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof myArray == "object", "<code>myArray</code> should be an <code>array</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof myArray[0] !== "undefined" && typeof myArray[0] == "string", "The first item in <code>myArray</code> should be a <code>string</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof myArray[1] !== "undefined" && typeof myArray[1] == "number", "The second item in <code>myArray</code> should be a <code>number</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourArray = ["John", 23];
|
||||
|
||||
// Only change code below this line.
|
||||
var myArray = [];
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244a8
|
||||
title: Storing Values with the Assignment Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(/var a;/.test(code) && /var b = 2;/.test(code), "Do not change code above the line");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof a === "number" && a === 7, "<code>a</code> should have a value of 7");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof b === "number" && b === 7, "<code>b</code> should have a value of 7");'
|
||||
- text: ''
|
||||
testString: 'assert(/b\s*=\s*a\s*;/g.test(code), "<code>a</code> should be assigned to <code>b</code> with <code>=</code>");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var a;
|
||||
var b = 2;
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### Before Test
|
||||
<div id='js-setup'>
|
||||
|
||||
```js
|
||||
if (typeof a != 'undefined') {
|
||||
a = undefined;
|
||||
}
|
||||
if (typeof b != 'undefined') {
|
||||
b = undefined;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,59 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb4bdef
|
||||
title: Subtract One Number from Another with JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(difference === 12, "Make the variable <code>difference</code> equal 12.");'
|
||||
- text: ''
|
||||
testString: 'assert(/var\s*difference\s*=\s*45\s*-\s*[0-9]*;(?!\s*[a-zA-Z0-9]+)/.test(code),"Only subtract one number from 45.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
var difference = 45 - 0;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: 567af2437cbaa8c51670a16c
|
||||
title: Testing Objects for Properties
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(checkObj("gift") === "pony", "<code>checkObj("gift")</code> should return <code>"pony"</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert(checkObj("pet") === "kitten", "<code>checkObj("pet")</code> should return <code>"kitten"</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert(checkObj("house") === "Not Found", "<code>checkObj("house")</code> should return <code>"Not Found"</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var myObj = {
|
||||
gift: "pony",
|
||||
pet: "kitten",
|
||||
bed: "sleigh"
|
||||
};
|
||||
|
||||
function checkObj(checkProp) {
|
||||
// Your Code Here
|
||||
|
||||
return "Change Me!";
|
||||
}
|
||||
|
||||
// Test your code by modifying these values
|
||||
checkObj("gift");
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ba
|
||||
title: Understand String Immutability
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(myStr === "Hello World", "<code>myStr</code> should have a value of <code>Hello World</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(/myStr = "Jello World"/.test(code), "Do not change the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Setup
|
||||
var myStr = "Jello World";
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
myStr[0] = "H"; // Fix Me
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: bd7123c9c441eddfaeb5bdef
|
||||
title: Understanding Boolean Values
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof welcomeToBooleans() === "boolean", "The <code>welcomeToBooleans()</code> function should return a boolean (true/false) value.");'
|
||||
- text: ''
|
||||
testString: 'assert(welcomeToBooleans() === true, "<code>welcomeToBooleans()</code> should return true.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function welcomeToBooleans() {
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
return false; // Change this line
|
||||
|
||||
// Only change code above this line.
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ab
|
||||
title: Understanding Case Sensitivity in Variables
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof studlyCapVar !== "undefined" && studlyCapVar === 10, "<code>studlyCapVar</code> is defined and has a value of <code>10</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof properCamelCase !== "undefined" && properCamelCase === "A String", "<code>properCamelCase</code> is defined and has a value of <code>"A String"</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof titleCaseOver !== "undefined" && titleCaseOver === 9000, "<code>titleCaseOver</code> is defined and has a value of <code>9000</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/studlyCapVar/g).length === 2, "<code>studlyCapVar</code> should use camelCase in both declaration and assignment sections.");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/properCamelCase/g).length === 2, "<code>properCamelCase</code> should use camelCase in both declaration and assignment sections.");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/titleCaseOver/g).length === 2, "<code>titleCaseOver</code> should use camelCase in both declaration and assignment sections.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Declarations
|
||||
var StUdLyCapVaR;
|
||||
var properCamelCase;
|
||||
var TitleCaseOver;
|
||||
|
||||
// Assignments
|
||||
STUDLYCAPVAR = 10;
|
||||
PRoperCAmelCAse = "A String";
|
||||
tITLEcASEoVER = 9000;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: 598e8944f009e646fc236146
|
||||
title: Understanding Undefined Value returned from a Function
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof addFive === "function", "<code>addFive</code> should be a function");'
|
||||
- text: ''
|
||||
testString: 'assert(sum === 8, "<code>sum</code> should be equal to 8");'
|
||||
- text: ''
|
||||
testString: 'assert(addFive() === undefined, "Returned value from <code>addFive</code> should be <code>undefined</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/(sum\s*\=\s*sum\s*\+\s*5)|(sum\s*\+\=\s*5)/g).length === 1, "Inside of your functions, add 5 to the <code>sum</code> variable");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var sum = 0;
|
||||
function addThree() {
|
||||
sum = sum + 3;
|
||||
}
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
var returnedValue = addFive();
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244aa
|
||||
title: Understanding Uninitialized Variables
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof a === "number" && a === 6, "<code>a</code> should be defined and evaluated to have the value of <code>6</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof b === "number" && b === 15, "<code>b</code> should be defined and evaluated to have the value of <code>15</code>");'
|
||||
- text: ''
|
||||
testString: 'assert(!/undefined/.test(c) && c === "I am a String!", "<code>c</code> should not contain <code>undefined</code> and should have a value of "I am a String!"");'
|
||||
- text: ''
|
||||
testString: 'assert(/a = a \+ 1;/.test(code) && /b = b \+ 5;/.test(code) && /c = c \+ " String!";/.test(code), "Do not change code below the line");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Initialize these three variables
|
||||
var a;
|
||||
var b;
|
||||
var c;
|
||||
|
||||
// Do not change code below this line
|
||||
|
||||
a = a + 1;
|
||||
b = b + 5;
|
||||
c = c + " String!";
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392d1
|
||||
title: Updating Object Properties
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(/happy coder/gi.test(myDog.name), "Update <code>myDog</code>'s <code>"name"</code> property to equal "Happy Coder".");'
|
||||
- text: ''
|
||||
testString: 'assert(/"name": "Coder"/.test(code), "Do not edit the <code>myDog</code> definition");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var ourDog = {
|
||||
"name": "Camper",
|
||||
"legs": 4,
|
||||
"tails": 1,
|
||||
"friends": ["everything!"]
|
||||
};
|
||||
|
||||
ourDog.name = "Happy Camper";
|
||||
|
||||
// Setup
|
||||
var myDog = {
|
||||
"name": "Coder",
|
||||
"legs": 4,
|
||||
"tails": 1,
|
||||
"friends": ["freeCodeCamp Campers"]
|
||||
};
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: bd7123c9c549eddfaeb5bdef
|
||||
title: Use Bracket Notation to Find the First Character in a String
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(firstLetterOfLastName === "L", "The <code>firstLetterOfLastName</code> variable should have the value of <code>L</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/firstLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var firstLetterOfFirstName = "";
|
||||
var firstName = "Ada";
|
||||
|
||||
firstLetterOfFirstName = firstName[0];
|
||||
|
||||
// Setup
|
||||
var firstLetterOfLastName = "";
|
||||
var lastName = "Lovelace";
|
||||
|
||||
// Only change code below this line
|
||||
firstLetterOfLastName = lastName;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: bd7123c9c451eddfaeb5bdef
|
||||
title: Use Bracket Notation to Find the Last Character in a String
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(lastLetterOfLastName === "e", "<code>lastLetterOfLastName</code> should be "e".");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the last letter.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var firstName = "Ada";
|
||||
var lastLetterOfFirstName = firstName[firstName.length - 1];
|
||||
|
||||
// Setup
|
||||
var lastName = "Lovelace";
|
||||
|
||||
// Only change code below this line.
|
||||
var lastLetterOfLastName = lastName;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: bd7123c9c450eddfaeb5bdef
|
||||
title: Use Bracket Notation to Find the Nth Character in a String
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(thirdLetterOfLastName === "v", "The <code>thirdLetterOfLastName</code> variable should have the value of <code>v</code>.");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var firstName = "Ada";
|
||||
var secondLetterOfFirstName = firstName[1];
|
||||
|
||||
// Setup
|
||||
var lastName = "Lovelace";
|
||||
|
||||
// Only change code below this line.
|
||||
var thirdLetterOfLastName = lastName;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: bd7123c9c452eddfaeb5bdef
|
||||
title: Use Bracket Notation to Find the Nth-to-Last Character in a String
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(secondToLastLetterOfLastName === "c", "<code>secondToLastLetterOfLastName</code> should be "c".");'
|
||||
- text: ''
|
||||
testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the second last letter.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
var firstName = "Ada";
|
||||
var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];
|
||||
|
||||
// Setup
|
||||
var lastName = "Lovelace";
|
||||
|
||||
// Only change code below this line
|
||||
var secondToLastLetterOfLastName = lastName;
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: cf1111c1c12feddfaeb3bdef
|
||||
title: Use Conditional Logic with If Statements
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: ''
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
|
||||
## Instructions
|
||||
undefined
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(typeof trueOrFalse === "function", "<code>trueOrFalse</code> should be a function");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof trueOrFalse(true) === "string", "<code>trueOrFalse(true)</code> should return a string");'
|
||||
- text: ''
|
||||
testString: 'assert(typeof trueOrFalse(false) === "string", "<code>trueOrFalse(false)</code> should return a string");'
|
||||
- text: ''
|
||||
testString: 'assert(trueOrFalse(true) === "Yes, that was true", "<code>trueOrFalse(true)</code> should return "Yes, that was true"");'
|
||||
- text: ''
|
||||
testString: 'assert(trueOrFalse(false) === "No, that was false", "<code>trueOrFalse(false)</code> should return "No, that was false"");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Example
|
||||
function ourTrueOrFalse(isItTrue) {
|
||||
if (isItTrue) {
|
||||
return "Yes, it's true";
|
||||
}
|
||||
return "No, it's false";
|
||||
}
|
||||
|
||||
// Setup
|
||||
function trueOrFalse(wasThatTrue) {
|
||||
|
||||
// Only change code below this line.
|
||||
|
||||
|
||||
|
||||
// Only change code above this line.
|
||||
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
trueOrFalse(true);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user