--- id: cf1111c1c12feddfaeb1bdef title: Generate Random Whole Numbers with JavaScript challengeType: 1 videoUrl: '' localeTitle: توليد أرقام كاملة عشوائية مع جافا سكريبت --- ## Description
من الرائع أن نتمكن من توليد أرقام عشرية عشوائية ، ولكنها أكثر فائدة إذا استخدمناها لإنشاء أرقام صحيحة عشوائية.
  1. استخدم Math.random() لإنشاء عشري عشوائي.
  2. اضرب هذا الرقم العشري العشوائي بـ 20 .
  3. استخدم دالة أخرى ، Math.floor() الرقم إلى أقرب رقم Math.floor() له.
تذكر أن Math.random() لا يمكنها أبدًا إرجاع 1 و ، نظرًا لأننا نقوم بالتقريب ، فمن المستحيل الحصول على 20 بالفعل. ستعطينا هذه التقنية عددًا صحيحًا بين 0 و 19 . وضع كل شيء معا ، وهذا هو ما تبدو عليه الكود لدينا: Math.floor(Math.random() * 20); نحن نطلق على Math.random() ، بضرب النتيجة بـ 20 ، ثم نمرر قيمة Math.floor() القيمة إلى أقرب رقم Math.floor() .
## Instructions
استخدم هذه التقنية لتوليد وإرجاع رقم صحيح عشوائي بين 0 و 9 .
## Tests
```yml tests: - text: يجب أن تكون نتيجة randomWholeNum . testString: 'assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), "The result of randomWholeNum should be a whole number.");' - text: يجب أن تستخدم Math.random لإنشاء رقم عشوائي. testString: 'assert(code.match(/Math.random/g).length > 1, "You should be using Math.random to generate a random number.");' - text: يجب أن تضاعف نتيجة Math.random بمقدار 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 Math.random by 10 to make it a number that is between zero and nine.");' - text: يجب عليك استخدام Math.floor لإزالة الجزء العشري من الرقم. testString: 'assert(code.match(/Math.floor/g).length > 1, "You should use Math.floor to remove the decimal part of the number.");' ```
## Challenge Seed
```js var randomNumberBetween0and19 = Math.floor(Math.random() * 20); function randomWholeNum() { // Only change code below this line. return Math.random(); } ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```