mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-23 21:04:36 -05:00
chore(i18n,learn): processed translations (#48588)
This commit is contained in:
@@ -8,7 +8,7 @@ dashedName: moving-forward-from-here
|
||||
|
||||
# --description--
|
||||
|
||||
تهانينا! أنهيت الدروس في React و Redux. هناك عنصر أخير يستحق الإشارة قبل المضي قدما. عادة، لن تكتب تطبيقات React في محرر التعليمات البرمجية مثل ذلك. هذا التحدي يعطيك لمحة من الشكل الذي تبدو عليه الجملة إذا كنت تعمل مع npm ونظام الملفات على جهازك الخاص. يجب أن تبدو التعليمات البرمجية متشابهة، باستثناء استخدام تعبيرات `import` (هذه تجذب في جميع التبعيات التي تم توفيرها لك في التحديات). قسم "Managing Packages with npm" يغطي npm بمزيد من التفصيل.
|
||||
تهانينا! أنهيت الدروس في React و Redux. هناك عنصر أخير يستحق الإشارة قبل المضي قدما. عادة، لن تكتب تطبيقات React في محرر التعليمات البرمجية مثل ذلك. هذا التحدي يعطيك لمحة من الشكل الذي تبدو عليه الجملة إذا كنت تعمل مع npm ونظام الملفات على جهازك الخاص. يجب أن يبدو كود متشابه، باستثناء استخدام تعبيرات `import` (هذه تجذب في جميع التبعيات (dependencies) التي تم توفيرها لك في التحديات). قسم "Managing Packages with npm" يغطي npm بمزيد من التفصيل.
|
||||
|
||||
وأخيرا، تتطلب كتابة تعليمات React و Redux البرمجية بعض الترتيب (configuration) عمومًا. وهذا يمكن أن يصبح معقدا بسرعة. إذا كنت مهتما بالتجربة على جهازك الخاص، فإن <a href="https://www.freecodecamp.org/news/install-react-with-create-react-app/" target="_blank" rel="noopener noreferrer nofollow">إنشاء تطبيق React</a> يتم تكوينه واستعداده للذهاب.
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
بمجرد تركيب المكون، الضغط على `enter` يجب أن تحدِيث حالته وعلامة `h1` المقدمة.
|
||||
بمجرد تركيب المكون (component)، يجب أن تحدِيث حالته (state) عند الضغط على `enter` وتحدِيث علامة `h1` المقدمة.
|
||||
|
||||
```js
|
||||
async () => {
|
||||
|
||||
@@ -8,17 +8,17 @@ dashedName: create-a-controlled-input
|
||||
|
||||
# --description--
|
||||
|
||||
قد يحتوي تطبيقك على تعامُلات أكثر تعقيدا بين `state` وواجهة المستخدم المقدمة (UI). على سبيل المثال، عناصر التحكم في النموذج للمدخلات النصية، مثل `input` و `textarea`، الحفاظ على حالتها الخاصة في DOM كنوع من المستخدم. مع React، يمكنك نقل هذه الحالة القابلة للتغيير إلى `state` للمكون React. يصبح إدخال المستخدم جزءا من التطبيق `state`، لذا يتحكم React في قيمة حقل الإدخال هذا. في الأغلب، إذا كان لديك مكونات React مع حقول الإدخال الذي يمكن للمستخدم أن يكتبها، فسيكون نموذج الإدخال المتحكم فيه.
|
||||
قد يحتوي تطبيقك على تعامُلات أكثر تعقيدا بين `state` وواجهة المستخدم المقدمة (UI). على سبيل المثال، عناصر التحكم في النموذج (form control) للمدخلات (inputs) النصية، مثل `input` و `textarea`، الحفاظ على حالتها (input) الخاصة في DOM عندما يكتب المستخدم. مع React، يمكنك نقل هذه الحالة (state) القابلة للتغيير إلى `state` للمكون (component) في React. يصبح إدخال (input) المستخدم جزءا من التطبيق `state`، لذا يتحكم React في قيمة حقل الإدخال (input field) هذا. في الأغلب، إذا كان لديك مكونات React مع حقول الإدخال الذي يمكن للمستخدم أن يكتبها، فسيكون نموذج الإدخال المتحكم فيه.
|
||||
|
||||
# --instructions--
|
||||
|
||||
يحتوي محرر التعليمات البرمجية على الهيكل العظمي لمكون يسمى `ControlledInput` لإنشاء عنصر `input` المتحكم بيه. تم فعلًا تهيئة `state` المكون مع خاصية `input` التي تحتوي على سلسلة فارغة. هذه القيمة تمثل نوع النص المستخدم في حقل `input`.
|
||||
يحتوي محرر التعليمات البرمجية على الهيكل العظمي لمكون يسمى `ControlledInput` لإنشاء عنصر `input` المتحكم بيه. تم فعلًا تهيئة `state` للمكون (component) مع خاصية (property) تسمى `input` التي تحتوي على مقطع نصي (string) فارغة. هذه القيمة تمثل نوع النص المستخدم في حقل `input`.
|
||||
|
||||
أولا، إنشاء طريقة تسمى `handleChange()` تحتوي على الوسيطة تسمى `event`. عندما يتم تسمية الطريقة، فإنها تتلقى كائن `event` يحتوي على سلسلة من النص من عنصر `input`. يمكنك الوصول إلى هذه السلسلة باستخدام `event.target.value` داخل الطريقة. حديث خاصية `input` في المكون `state` مع هذه السلسلة الجديدة.
|
||||
أولا، إنشاء طريقة تسمى `handleChange()` تحتوي على الوسيطة تسمى `event`. عندما يتم تسمية الطريقة، فإنها تتلقى كائن `event` يحتوي على سلسلة من النص من عنصر `input`. يمكنك الوصول إلى هذه السلسلة باستخدام `event.target.value` داخل الطريقة. حديث خاصية (property) تسمى `input` في `state` للمكون (component) مع هذا المقطع النصي (string) الجديدة.
|
||||
|
||||
في طريقة `render`، أنشئ عنصر `input` فوق علامة `h4`. أضف خاصية `value` تساوي خاصية `input` في المكون `state`. ثم أضف معالج الحدث `onChange()` إلى طريقة `handleChange()`.
|
||||
في طريقة `render`، أنشئ عنصر `input` فوق علامة `h4`. أضف سمة (attribute) تسمى `value` تساوي خاصية (property) تسمى `input` في `state` للمكون (component). ثم أضف معالج الحدث `onChange()` إلى طريقة `handleChange()`.
|
||||
|
||||
عندما تكتب في صندوق الإدخال، يتم معالجة هذا النص بواسطة طريقة `handleChange()`، تُعيين كخاصية `input` في `state` المحلية، وتم أنتاجها كقيمة في صندوق `input` على الصفحة. المكون `state` هو المصدر الوحيد للحقيقة (single source of truth) فيما يتعلق ببيانات الإدخال.
|
||||
عندما تكتب في صندوق الإدخال (input)، يتم معالجة هذا النص بواسطة طريقة (method) تسمى `handleChange()`، تُعيين كخاصية (property) تسمى `input` في `state` المحلية، وتم أنتاجها كقيمة في صندوق `input` على الصفحة. تكون `state` المكون (component) المصدر الوحيد للحقيقة (single source of truth) فيما يتعلق ببيانات الإدخال (input).
|
||||
|
||||
أخيرا وليس آخرا، لا تنس أن تضيف الارتباطات اللازمة في البناء (constructor).
|
||||
|
||||
@@ -39,7 +39,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
حالة `ControlledInput` يجب أن تهيئ خاصية `input` محددة إلى سلسلة فارغة.
|
||||
يجب أن تهيئ حالة (state) في `ControlledInput` خاصية (property) تسمى `input` بقيمة مقطع فارغ (string).
|
||||
|
||||
```js
|
||||
assert.strictEqual(
|
||||
@@ -48,7 +48,7 @@ assert.strictEqual(
|
||||
);
|
||||
```
|
||||
|
||||
الكتابة في عنصر الإدخال يجب أن تحديث الحالة (state) وقيمة الإدخال (input)، و عنصر `p` يجب أن يجعل هذه الحالة (state) كما تكتب.
|
||||
يجب أن تحديث الحالة (state) عند الكتابة في عنصر الإدخال (input) وتحديث قيمة الإدخال (input)، و يجب أن يجعل عنصر `p` هذه الحالة (state) كما تكتب.
|
||||
|
||||
```js
|
||||
async () => {
|
||||
|
||||
@@ -10,9 +10,9 @@ dashedName: create-a-stateless-functional-component
|
||||
|
||||
المكونات هي مركز React. كل شيء في React هو مكون وسوف تتعلم كيفية إنشاء مكون.
|
||||
|
||||
هناك طريقتان لإنشاء مكون React. الطريقة الأولى هي استخدام وظيفية JavaScript. تعريف المكون بهذه الطريقة يخلق مكون *وظيفي عديم الحالة*. وسيتم تناول مفهوم الحالة (state) في التطبيق في تحديات لاحقة. في الوقت الحاضر، فكر في المكون عديم الحالة كمكون يمكن أن يتلقى البيانات ويقدمها، ولكنه لا يدير أو يتتبع التغييرات في تلك البيانات. (سنقوم بتغطية الطريقة الثانية لإنشاء عنصر React في التحدي التالي.)
|
||||
هناك طريقتان لإنشاء مكون React. الطريقة الأولى هي استخدام وظيفية JavaScript. تعريف المكون (component) بهذه الطريقة يخلق مكون *مكون وظيفي عديم الحالة (stateless functional component)*. وسيتم تناول مفهوم الحالة (state) في التطبيق في تحديات لاحقة. في الوقت الحاضر، فكر في المكون عديم الحالة (stateless component) كمكون يمكن أن يتلقى البيانات ويقدمها، ولكنه لا يدير أو يتتبع التغييرات في تلك البيانات. (سنقوم بتغطية الطريقة الثانية لإنشاء عنصر React في التحدي التالي.)
|
||||
|
||||
لإنشاء مكون مع وظيفة، يمكنك ببساطة كتابة دالة JavaScript التي تنتج إما JSX أو `null`. من الأمور المهمة التي نلاحظها أن React يتطلب اسم الوظيفية الخاص بك أن يبدأ بحرف كبير. إليك مثال لمكون وظيفي عديم الحالة يعيين فئة HTML في JSX:
|
||||
لإنشاء مكون مع وظيفة، يمكنك ببساطة كتابة دالة JavaScript التي تنتج إما JSX أو `null`. من الأمور المهمة التي نلاحظها أن React يتطلب اسم الوظيفية الخاص بك أن يبدأ بحرف كبير. إليك مثال لمكون وظيفي عديم الحالة (stateless functional component) يعيين فئة (class) من HTML في JSX:
|
||||
|
||||
```jsx
|
||||
const DemoComponent = function() {
|
||||
|
||||
@@ -8,15 +8,15 @@ dashedName: pass-state-as-props-to-child-components
|
||||
|
||||
# --description--
|
||||
|
||||
لقد رأيتم الكثير من الأمثلة التي انتقلت إلى عناصر JSX الفرعية ومكونات React الفرعية في التحديات السابقة. ربما تتساءل من أين تأتي تلك المِيزات (props). النمط الشائع هو أن يكون هناك مكون حالة يحتوي على `state` مهمة للتطبيق الخاص بك، ثم ينتج مكونات فرعية. تريد أن يكون لهذه المكونات حق الوصول إلى بعض القطع من تلك `state`، التي تمرّ مِيزات (props).
|
||||
لقد رأيتم الكثير من الأمثلة التي انتقلت إلى عناصر JSX الفرعية ومكونات React الفرعية في التحديات السابقة. ربما تتساءل من أين تأتي تلك المِيزات (props). النمط الشائع هو أن يكون هناك مكون حالة (stateful component) يحتوي على `state` مهمة لتطبيقك، ثم ينتج مكونات فرعية (child components). تريد أن يكون لهذه المكونات (components) حق الوصول إلى بعض القطع من تلك `state`، التي تمرّ مِيزات (props).
|
||||
|
||||
على سبيل المثال، ربما لديك مكون `App` الذي ينتج `Navbar`, من بين مكونات أخرى. في `App` الخاص بك، لديك `state` تحتوي على الكثير من معلومات المستخدم، ولكن `Navbar` يحتاج فقط إلى الوصول إلى اسم المستخدم حتى يتمكن من عرضه. تمرير هذه القطعة من `state` إلى مكون `Navbar` كمِيزة.
|
||||
على سبيل المثال، ربما لديك مكون `App` الذي ينتج `Navbar`, من بين مكونات أخرى. في `App` الخاص بك، لديك `state` تحتوي على الكثير من معلومات المستخدم، ولكن `Navbar` يحتاج فقط إلى الوصول إلى اسم المستخدم حتى يتمكن من عرضه. تمرير هذه القطعة من `state` إلى مكون (component) يسمى `Navbar` كمِيزة (prop).
|
||||
|
||||
ويوضح هذا النمط بعض الأنموذجات (paradigms) الهامة في React. الأول هو *تدفق البيانات الأحادية الاتجاه (unidirectional data flow)*. تتدفق الدولة في اتجاه واحد لأسفل شجرة عناصر تطبيقك، من مكون الحالة الأساسي (stateful parent component) إلى مكونات الفرعية (child components). ولا تحصل مكونات الفرعية إلا على بيانات الحالة التي تحتجاها. والثاني هو أن تطبيقات الحالة المعقدة (complex stateful apps) يمكن تقسيمها إلى مكونات قليلة أو ربما إلى مكون واحد من مكونات الحالة (stateful component). بقية المكونات الخاصة بك تتلقى ببساطة الحالة من الأصل كميزات، وتنتج واجهة المستخدم (UI) من تلك الحالة. يبدأ في إنشاء فصل حيث يتم التعامل مع إدارة الحالة في جزء واحد من الكود و واجهة المستخدم (UI) الذي يتم تقديمه في جزء آخر. هذا المبدأ لفصل منطق الحالة عن منطق واجهة المستخدم (UI) هو أحد المبادئ React الرئيسية. عندما يتم استخدامها بشكل صحيح، فإنها تجعل تصميم التطبيقات المعقدة ذات الصَّلاحِيَة (stateful applications) أسهل بكثير لإدارتها.
|
||||
ويوضح هذا النمط بعض الأنموذجات (paradigms) الهامة في React. الأول هو *تدفق البيانات الأحادية الاتجاه (unidirectional data flow)*. تتدفق الحالة (state) في اتجاه واحد لأسفل شجرة عناصر تطبيقك، من مكون الحالة الأساسي (stateful parent component) إلى مكونات الفرعية (child components). ولا تحصل مكونات الفرعية (child components) إلا على بيانات الحالة (state) التي تحتجاها. والثاني هو أن تطبيقات الحالة المعقدة (complex stateful apps) يمكن تقسيمها إلى مكونات قليلة أو ربما إلى مكون واحد (component) من مكونات الحالة (stateful component). بقية مكوناتك (components) تتلقى ببساطة الحالة (state) من الأصل كميزات (props)، وتنتج واجهة المستخدم (UI) من تلك الحالة (state). يبدأ في إنشاء فصل حيث يتم التعامل مع إدارة الحالة (state) في جزء واحد من الكود و واجهة المستخدم (UI) الذي يتم تقديمه في جزء آخر. هذا المبدأ لفصل منطق الحالة (state) عن منطق واجهة المستخدم (UI) هو أحد المبادئ React الرئيسية. عندما يتم استخدامها بشكل صحيح، فإنها تجعل تصميم التطبيقات المعقدة ذات الصَّلاحِيَة (stateful applications) أسهل بكثير لإدارتها.
|
||||
|
||||
# --instructions--
|
||||
|
||||
مكون `MyApp` هو مكون حالة ويجعل `Navbar` مكوناً فرعياً. اجتياز خاصية `name` في `state` خاصة بها لأسفل إلى عنصر الفرعي، ثم إظهار `name` في العلامة `h1` التي هي جزء من طريقة التقديم `Navbar`. `name` يجب أن يظهر بعد النص `Hello, my name is:`.
|
||||
مكون `MyApp` هو مكون حالة (stateful component) ويجعل `Navbar` مكوناً فرعياً (child component). اجتياز خاصية (property) تسمى `name` في `state` خاصة بها لأسفل إلى مكون الفرعي (child component)، ثم إظهار `name` في العلامة `h1` التي هي جزء من طريقة (method) تقديم `Navbar`. `name` يجب أن يظهر بعد النص `Hello, my name is:`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -34,7 +34,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
يجب أن يتلقى مكون `Navbar` إلى `MyApp` خاصية الحالة `name` كمِيزات.
|
||||
يجب أن يتلقى مكون (component) مسمى `Navbar` إلى `MyApp` خاصية الحالة (state property) تسمى `name` كمِيزات (props).
|
||||
|
||||
```js
|
||||
async () => {
|
||||
|
||||
@@ -8,17 +8,17 @@ dashedName: use--for-a-more-concise-conditional
|
||||
|
||||
# --description--
|
||||
|
||||
لقد نجحت تعبيرات `if/else` في التحدي السابق، ولكن هناك طريقة أكثر إيجازاً لتحقيق نفس النتيجة. تخيل أنك تتتبع عدة شروط في مكون وأنت تريد عناصر مختلفة أن تنتج تبعاً كل من هذه الشروط. إذا كتبت الكثير من تعبيرات `else if` لإنشاء واجهة مستخدم مختلفة (UI) قليلاً، فيمكنك تكرار التعليمات البرمجية التي تترك مجال للخطأ. بدلاً من ذلك، يمكنك استخدام `&&` المشغل المنطقي (logical operators) لتنفيذ المنطق المشروط (conditional logic) بطريقة أكثر إيجازاً. هذا ممكن لأنك تريد التحقق من أن الشرط هو `true`، وإذا كان الأمر كذلك، إرجاع بعض العلامة. إليك مثال:
|
||||
لقد نجحت تعبيرات `if/else` في التحدي السابق، ولكن هناك طريقة أكثر إيجازاً لتحقيق نفس النتيجة. تخيل أنك تتتبع عدة شروط في مكون وأنت تريد عناصر مختلفة أن تنتج تبعاً كل من هذه الشروط. إذا كتبت الكثير من تعبيرات `else if` لإنشاء واجهة مستخدم مختلفة (UI) قليلاً، فيمكنك تكرار كود الذي يترك مجال للخطأ. بدلاً من ذلك، يمكنك استخدام `&&` المشغل المنطقي (logical operators) لتنفيذ المنطق المشروط (conditional logic) بطريقة أكثر إيجازاً. هذا ممكن لأنك تريد التحقق من أن الشرط هو `true`، وإذا كان الأمر كذلك، إرجاع بعض العلامة. إليك مثال:
|
||||
|
||||
```jsx
|
||||
{condition && <p>markup</p>}
|
||||
```
|
||||
|
||||
إذا كان `condition` تكون `true`، سيتم إرجاع العلامة. إذا كان الشرط هو `false`، فإن العملية سوف تعود `false` فوراً بعد قياس `condition` وعدم إرجاع أي شيء. يمكنك تضمين هذه البيانات قاصدًا في JSX الخاص بك وكتابة الشروط المتعددة (string multiple conditions) معاً بكتابة `&&` بعد كل واحدة منها. يتيح لك هذا التعامل مع المنطق الشرطي الأكثر تعقيداً في طريقة `render()` الخاصة بك دون تكرار الكثير من التعليمات البرمجية.
|
||||
إذا كان `condition` تكون `true`، سيتم إرجاع العلامة. إذا كان الشرط هو `false`، فإن العملية سوف تعود `false` فوراً بعد قياس `condition` وعدم إرجاع أي شيء. يمكنك تضمين هذه التعبيرات في JSX الخاص بك قاصدًا, وكتابة الشروط المتعددة (string multiple conditions) معاً بكتابة `&&` بعد كل واحدة منها. يتيح لك هذا التعامل مع المنطق الشرطي الأكثر تعقيداً في طريقة `render()` الخاصة بك دون تكرار الكثير من التعليمات البرمجية.
|
||||
|
||||
# --instructions--
|
||||
|
||||
حل المثال السابق مرة أخرى، لذلك `h1` فقط إذا `display` تكون `true`، ولكن استخدم `&&` المشغل المنطقي بدلاً من `if/else`.
|
||||
حل المثال السابق مرة أخرى، لتقديد `h1` فقط إذا كان `display` بحالة `true`، ولكن استخدم `&&` المشغل المنطقي بدلاً من `if/else`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -75,7 +75,7 @@ async () => {
|
||||
};
|
||||
```
|
||||
|
||||
يجب أن تستخدم طريقة التقديم `&&` المشغل المنطقي (logical operator) للتحقق من حالة `this.state.display`.
|
||||
يجب أن تستخدم طريقة (method) التقديم `&&` المشغل المنطقي (logical operator) للتحقق من `this.state.display`.
|
||||
|
||||
```js
|
||||
(getUserInput) => assert(getUserInput('index').includes('&&'));
|
||||
|
||||
@@ -16,7 +16,7 @@ let onlineUsers = users.filter(user => user.online);
|
||||
|
||||
# --instructions--
|
||||
|
||||
في محرر التعليمات البرمجية، تم تهيئة `MyComponent` في `state` تحمل قائمة من المستخدمين. بعض المستخدمين على الإنترنت وبعضهم لا يفعل ذلك. تصفية القائمة بحيث ترى فقط المستخدمين الذين هم على الإنترنت. للقيام بذلك، أولاً استخدم `filter` لإرجاع قائمة جديدة تحتوي فقط على المستخدمين الذين خاصية `online` بقيمة `true`. ثم في متغير `renderOnline` تعيين (map) القائمة المصفى، و إرجاع عنصر `li` لكل مستخدم يحتوي على نص `username` الخاص به. تحقق تضمين `key` فريد أيضا، مثل التحديات السابقة.
|
||||
في محرر الكود، تم تهيئة `MyComponent` في `state` تحمل قائمة (array) من المستخدمين. بعض المستخدمين على الإنترنت وبعضهم لا يفعل ذلك. تصفية القائمة بحيث ترى فقط المستخدمين الذين هم على الإنترنت. للقيام بذلك، أولاً استخدم `filter` لإرجاع قائمة جديدة تحتوي فقط على المستخدمين الذين خاصية `online` بقيمة `true`. ثم في متغير `renderOnline` تعيين (map) القائمة المصفى، و إرجاع عنصر `li` لكل مستخدم يحتوي على نص `username` الخاص به. تحقق تضمين `key` فريد أيضا، مثل التحديات السابقة.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -29,7 +29,7 @@ assert.strictEqual(
|
||||
);
|
||||
```
|
||||
|
||||
يجب تهيئة حالة `MyComponent` لقائمة من المستخدمين الستة.
|
||||
يجب تهيئة حالة (state) في `MyComponent` لقائمة (array) من المستخدمين الستة.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
||||
@@ -8,9 +8,9 @@ dashedName: define-a-redux-action
|
||||
|
||||
# --description--
|
||||
|
||||
وبما أن Redux هو framework لإدارة الحالة، فإن تحديث الحالة هو أحد مهامها الأساسية. في Redux، يتم تشغيل جميع تحديثات الحالة عن طريق إرسال الإجراءات (actions). الإجراء (action) هو ببساطة كائن JavaScript الذي يحتوي على معلومات حول إجراء حدث الذي وقع. يستقبل متجر Redux هذه العناصر الإجرائية (action)، ثم تحديث حالته وفقاً لذلك. وفي بعض الأحيان يحمل إجراء Redux أيضا بعض البيانات. على سبيل المثال، يحمل الإجراء (action) اسم مستخدم بعد تسجيل دخول المستخدم. في حين أن البيانات اختيارية، يجب أن تحمل الإجراءات خاصية `type` التي تحدد 'نوع' الإجراء الذي وقع.
|
||||
وبما أن Redux هو framework لإدارة الحالة (state)، فإن تحديث الحالة (state) هو أحد مهامها الأساسية. في Redux، يتم تشغيل جميع تحديثات الحالة (state) عن طريق إرسال الإجراءات (actions). الإجراء (action) هو ببساطة كائن JavaScript الذي يحتوي على معلومات حول إجراء حدث الذي وقع. يستقبل متجر Redux هذه العناصر الإجرائية (action)، ثم تحديث حالته (state) وفقاً لذلك. وفي بعض الأحيان يحمل إجراء Redux أيضا بعض البيانات. على سبيل المثال، يحمل الإجراء (action) اسم مستخدم بعد تسجيل دخول المستخدم. في حين أن البيانات اختيارية، يجب أن تحمل الإجراءات خاصية `type` التي تحدد 'نوع' الإجراء الذي وقع.
|
||||
|
||||
فكر إن الإجراءات Redux كمراسلين يسليمون معلومات عن الأحداث التي تقع في التطبيق الخاص بك فى متجر Redux. ثم يقوم المتجر بأعمال تحديث للحالة استناداً على الإجراء الذي وقع.
|
||||
فكر إن الإجراءات Redux كمراسلين يسليمون معلومات عن الأحداث التي تقع في التطبيق الخاص بك فى متجر Redux. ثم يقوم المتجر (store) بأعمال تحديث للحالة (state) استناداً على الإجراء (action) الذي وقع.
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ dashedName: use-if-and-else-to-add-logic-to-your-styles
|
||||
|
||||
# --description--
|
||||
|
||||
التوجيه `@if` في Sass مفيد لاختبار حالة محددة - إنه يعمل تماما مثل `if` بيان في JavaScript.
|
||||
التوجيه `@if` في Sass مفيد لاختبار حالة محددة - إنه يعمل تماما مثل `if` تعبير في JavaScript.
|
||||
|
||||
```scss
|
||||
@mixin make-bold($bool) {
|
||||
@@ -57,7 +57,7 @@ heavy - 6px solid black
|
||||
assert(code.match(/@mixin\s+?border-stroke\s*?\(\s*?\$val\s*?\)\s*?{/gi));
|
||||
```
|
||||
|
||||
يجب أن يكون لدى mixin الخاص بك تعبير `@if` يتحقق مما إذا كان `$val` هو `light`، ولتحديد `border` بقيمة `1px solid black`.
|
||||
يجب أن يكون لديك تعبير mixin من `@if` يتحقق مما إذا كان `$val` هو `light`، ولتحديد `border` بقيمة `1px solid black`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@@ -67,7 +67,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
يجب أن يكون لدى mixin الخاص بك تعبير `@else if` يتحقق مما إذا كان `$val` هو `medium`، ولتحديد `border` بقيمة `3px solid black`.
|
||||
يجب أن يكون لديك تعبير mixin من `@else if` يتحقق مما إذا كان `$val` هو `medium`، ولتحديد `border` بقيمة `3px solid black`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@@ -77,7 +77,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
يجب أن يكون لدى mixin الخاص بك تعبير `@else if` يتحقق مما إذا كان `$val` هو `heavy`، ولتحديد `border` بقيمة `6px solid black`.
|
||||
يجب أن يكون لديك تعبير mixin من `@else if` يتحقق مما إذا كان `$val` هو `heavy`، ولتحديد `border` بقيمة `6px solid black`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@@ -87,7 +87,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
يجب أن يحتوي mixin الخاص بك على تعبير `@else` لتحديد `border` إلى `none`.
|
||||
يجب أن يكون لديك تعبير mixin من `@else` لتحديد `border` إلى `none`.
|
||||
|
||||
```js
|
||||
assert(code.match(/@else\s*?{\s*?border\s*?:\s*?none\s*?;\s*?}/gi));
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-exercisetracker" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-filemetadata" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-headerparser" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-timestamp" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
**Note:** Time zones conversion is not a purpose of this project, so assume all sent valid dates will be parsed with `new Date()` as GMT dates.
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-urlshortener" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Working on these challenges will involve you writing your code using one of the
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-express" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete these challenges.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
During the development process, it is important to be able to check what’s going on in your code.
|
||||
|
||||
@@ -14,6 +14,12 @@ Working on these challenges will involve you writing your code using one of the
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-npm" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete these challenges.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
The `package.json` file is the center of any Node.js project or npm package. It stores information about your project, similar to how the <head> section of an HTML document describes the content of a webpage. It consists of a single JSON object where information is stored in key-value pairs. There are only two required fields; "name" and "version", but it’s good practice to provide additional information about your project that could be useful to future users or maintainers.
|
||||
|
||||
@@ -14,6 +14,12 @@ Working on these challenges will involve you writing your code using one of the
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-mongomongoose" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete these challenges.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
In this challenge, you will set up a MongoDB Atlas database and import the required packages to connect to it.
|
||||
|
||||
@@ -14,6 +14,12 @@ Working on these challenges will involve you writing your code using one of the
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-advancednode" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete these challenges.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
A template engine enables you to use static template files (such as those written in *Pug*) in your app. At runtime, the template engine replaces variables in a template file with actual values which can be supplied by your server. Then it transforms the template into a static HTML file that is sent to the client. This approach makes it easier to design an HTML page and allows for displaying variables on the page without needing to make an API call from the client.
|
||||
|
||||
@@ -14,6 +14,12 @@ Working on these challenges will involve you writing your code using one of the
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-mochachai" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete these challenges.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-american-british-english-translator" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-issuetracker" target="_blank" rel="noopener noreferrer nofollow">this Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-metricimpconverter" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-library" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Build a full stack JavaScript app that is functionally similar to this: <a href=
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-sudoku-solver" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: arithmetic-formatter
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-arithmetic-formatter" target="_blank" rel="noopener noreferrer nofollow"> working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
Students in primary school often arrange arithmetic problems vertically to make them easier to solve. For example, "235 + 52" becomes:
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: budget-app
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-budget-app" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
Complete the `Category` class in `budget.py`. It should be able to instantiate objects based on different budget categories like *food*, *clothing*, and *entertainment*. When objects are created, they are passed in the name of the category. The class should have an instance variable called `ledger` that is a list. The class should also contain the following methods:
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: polygon-area-calculator
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-polygon-area-calculator" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
In this project you will use object oriented programming to create a Rectangle class and a Square class. The Square class should be a subclass of Rectangle and inherit methods and attributes.
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: probability-calculator
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-probability-calculator" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
Suppose there is a hat containing 5 blue balls, 4 red balls, and 2 green balls. What is the probability that a random draw of 4 balls will contain at least 1 red ball and 2 green balls? While it would be possible to calculate the probability using advanced mathematics, an easier way is to write a program to perform a large number of experiments to estimate an approximate probability.
|
||||
|
||||
@@ -10,6 +10,10 @@ dashedName: time-calculator
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-time-calculator" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function named `add_time` that takes in two required parameters and one optional parameter:
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: demographic-data-analyzer
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-demographic-data-analyzer" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
We are still developing the interactive instructional part of the Python curriculum. For now, here are some videos on the freeCodeCamp.org YouTube channel that will teach you everything you need to know to complete this project:
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a> (14 hours)
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: mean-variance-standard-deviation-calculator
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-mean-variance-standard-deviation-calculator" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
We are still developing the interactive instructional part of the Python curriculum. For now, here are some videos on the freeCodeCamp.org YouTube channel that will teach you everything you need to know to complete this project:
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: medical-data-visualizer
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-medical-data-visualizer" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
We are still developing the interactive instructional part of the Python curriculum. For now, here are some videos on the freeCodeCamp.org YouTube channel that will teach you everything you need to know to complete this project:
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: page-view-time-series-visualizer
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-page-view-time-series-visualizer" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
We are still developing the interactive instructional part of the Python curriculum. For now, here are some videos on the freeCodeCamp.org YouTube channel that will teach you everything you need to know to complete this project:
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: sea-level-predictor
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-sea-level-predictor" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
We are still developing the interactive instructional part of the Python curriculum. For now, here are some videos on the freeCodeCamp.org YouTube channel that will teach you everything you need to know to complete this project:
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
@@ -16,6 +16,12 @@ Working on this project will involve you writing your code using one of the foll
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-messageboard" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -11,6 +11,11 @@ dashedName: port-scanner
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-port-scanner" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
We are still developing the interactive instructional part of the Python curriculum. For now, here are some videos on the freeCodeCamp.org YouTube channel that will teach you everything you need to know to complete this project:
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a> (14 hours)
|
||||
|
||||
@@ -14,6 +14,12 @@ Develop a 2D real time multiplayer game using the HTML Canvas API and Socket.io
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-secure-real-time-multiplayer-game" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -11,6 +11,11 @@ dashedName: sha-1-password-cracker
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-SHA-1-password-cracker" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
We are still developing the interactive instructional part of the Python curriculum. For now, here are some videos on the freeCodeCamp.org YouTube channel that will teach you everything you need to know to complete this project:
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a> (14 hours)
|
||||
|
||||
@@ -18,6 +18,12 @@ Working on this project will involve you writing your code using one of the foll
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-project-stockchecker" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -14,6 +14,12 @@ Working on these challenges will involve you writing your code using one of the
|
||||
- Use <a href="https://replit.com/github/freeCodeCamp/boilerplate-infosec" target="_blank" rel="noopener noreferrer nofollow">our Replit starter project</a> to complete these challenges.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
Helmet helps you secure your Express apps by setting various HTTP headers.
|
||||
|
||||
@@ -12,6 +12,10 @@ For this challenge, you will create a program to play Rock, Paper, Scissors. A p
|
||||
|
||||
You will be <a href="https://replit.com/github/freeCodeCamp/boilerplate-rock-paper-scissors" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Replit starter code</a>.
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
We are still developing the interactive instructional part of the machine learning curriculum. For now, you will have to use other resources to learn how to pass this challenge.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-43
|
||||
|
||||
# --description--
|
||||
|
||||
Increase the pseudo-element's transparency by `30%`.
|
||||
زد شفافية (transparency) العنصر الزائف (pseudo-element) بنسبة `30%`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@@ -14,13 +14,19 @@ dashedName: exercise-tracker
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-exercisetracker" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
你的答案應該有以下結構。
|
||||
Your responses should have the following structures.
|
||||
|
||||
運動:
|
||||
Exercise:
|
||||
|
||||
```js
|
||||
{
|
||||
@@ -32,7 +38,7 @@ dashedName: exercise-tracker
|
||||
}
|
||||
```
|
||||
|
||||
用戶:
|
||||
User:
|
||||
|
||||
```js
|
||||
{
|
||||
@@ -41,7 +47,7 @@ dashedName: exercise-tracker
|
||||
}
|
||||
```
|
||||
|
||||
日誌:
|
||||
Log:
|
||||
|
||||
```js
|
||||
{
|
||||
@@ -56,11 +62,11 @@ dashedName: exercise-tracker
|
||||
}
|
||||
```
|
||||
|
||||
**提示:** 對於 `date` 屬性,`Date` API 的 `toDateString` 方法可以用於實現預期的輸出。
|
||||
**Hint:** For the `date` property, the `toDateString` method of the `Date` API can be used to achieve the expected output.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -71,7 +77,7 @@ dashedName: exercise-tracker
|
||||
};
|
||||
```
|
||||
|
||||
可以將表單裏的 `username` 通過 `POST` 請求發送到 `/api/users`,以創建一個新的用戶。
|
||||
You can `POST` to `/api/users` with form data `username` to create a new user.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -88,7 +94,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`POST /api/users` 帶有表單數據 `username` 對請求,返回的響應將是一個具有 `username` 和 `_id` 屬性的對象.
|
||||
The returned response from `POST /api/users` with form data `username` will be an object with `username` and `_id` properties.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -108,7 +114,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/users` 發出 `GET` 請求以獲取所有用戶的列表。
|
||||
You can make a `GET` request to `/api/users` to get a list of all users.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -121,7 +127,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
對 `/api/users` 的 `GET` 請求返回一個數組。
|
||||
The `GET` request to `/api/users` returns an array.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -136,7 +142,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
從 `GET /api/users` 返回的數組中的每個元素都是一個對象字面量,包含用戶的 `username` 和 `_id`。
|
||||
Each element in the array returned from `GET /api/users` is an object literal containing a user's `username` and `_id`.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -156,7 +162,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你能用表單裏的 `description`、`duration` 和 `date`(可選)發送 `POST` 請求到 `/api/users/:_id/exercises`。 如果沒有傳入 date,默認採用當前日期。
|
||||
You can `POST` to `/api/users/:_id/exercises` with form data `description`, `duration`, and optionally `date`. If no date is supplied, the current date will be used.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -190,7 +196,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
從 `POST /api/users/:_id/exercises` 返回的響應將是添加了運動字段的用戶對象。
|
||||
The response returned from `POST /api/users/:_id/exercises` will be the user object with the exercise fields added.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -229,7 +235,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以發送 `GET` 請求到 `/api/users/:_id/logs`,以獲取任何用戶的完整 exercise 日誌。
|
||||
You can make a `GET` request to `/api/users/:_id/logs` to retrieve a full exercise log of any user.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -268,7 +274,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
對用戶日誌的請求 `GET /api/users/:_id/logs` 返回一個用戶對象,該對象具有一個 `count` 屬性,表示屬於該用戶的運動次數。
|
||||
A request to a user's log `GET /api/users/:_id/logs` returns a user object with a `count` property representing the number of exercises that belong to that user.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -309,7 +315,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
對 `/api/users/:_id/logs` 的 `GET` 請求,將返回用戶對象,其中包含添加的所有練習的 `log` 數組。
|
||||
A `GET` request to `/api/users/:_id/logs` will return the user object with a `log` array of all the exercises added.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -353,7 +359,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
從 `GET /api/users/:_id/logs` 返回的 `log` 數組中的每個項目都是一個應該具有 `description`、`duration` 和 `date` 屬性的對象。
|
||||
Each item in the `log` array that is returned from `GET /api/users/:_id/logs` is an object that should have a `description`, `duration`, and `date` properties.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -400,7 +406,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
從 `GET /api/users/:_id/logs` 返回的 `log` 數組中任何對象的 `description` 屬性都應該是一個字符串。
|
||||
The `description` property of any object in the `log` array that is returned from `GET /api/users/:_id/logs` should be a string.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -447,7 +453,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
從 `GET /api/users/:_id/logs` 返回的 `log` 數組中任何對象的 `duration` 屬性應該是一個數字。
|
||||
The `duration` property of any object in the `log` array that is returned from `GET /api/users/:_id/logs` should be a number.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -494,7 +500,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
從 `GET /api/users/:_id/logs` 返回的 `log` 數組中任何對象的 `date` 屬性應該是一個字符串。 使用 `Date` API 的 `dateString` 格式。
|
||||
The `date` property of any object in the `log` array that is returned from `GET /api/users/:_id/logs` should be a string. Use the `dateString` format of the `Date` API.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -541,7 +547,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以將 `from`、`to` 和 `limit` 參數添加到 `GET /api/users/:_id/logs` 請求檢索任何用戶的部分日誌。 `from` 和 `to` 是 `yyyy-mm-dd` 形式的日期, `limit` 是希望返回的 log 數量。
|
||||
You can add `from`, `to` and `limit` parameters to a `GET /api/users/:_id/logs` request to retrieve part of the log of any user. `from` and `to` are dates in `yyyy-mm-dd` format. `limit` is an integer of how many logs to send back.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,15 +14,21 @@ dashedName: file-metadata-microservice
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-filemetadata" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
** 提示:** 可以使用 `multer` npm 包來處理上傳文件
|
||||
**HINT:** You can use the `multer` npm package to handle file uploading.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -34,7 +40,7 @@ dashedName: file-metadata-microservice
|
||||
};
|
||||
```
|
||||
|
||||
可以提交一個包含上傳文件的表單。
|
||||
You can submit a form that includes a file upload.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -45,7 +51,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
表單的文件上傳標籤的 `name` 屬性設置成 `upfile`。
|
||||
The form file input field has the `name` attribute set to `upfile`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -56,7 +62,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
當提交一個文件時,在 JSON 響應中收到文件的 `name`、`type` 和`size`(以 bytes(字節)爲單位)。
|
||||
When you submit a file, you receive the file `name`, `type`, and `size` in bytes within the JSON response.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,11 +14,17 @@ dashedName: request-header-parser-microservice
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-headerparser" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -30,7 +36,7 @@ dashedName: request-header-parser-microservice
|
||||
};
|
||||
```
|
||||
|
||||
向 `/api/whoami` 發送請求,返回一個 JSON 對象,這個JSON 對象應該含有存放 IP 地址的 `ipaddress` 鍵中。
|
||||
A request to `/api/whoami` should return a JSON object with your IP address in the `ipaddress` key.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -42,7 +48,7 @@ dashedName: request-header-parser-microservice
|
||||
);
|
||||
```
|
||||
|
||||
向 `/api/whoami` 發送請求,返回一個 JSON 對象,這個 JSON 對象應該含有存放語言首選項的 `language` 鍵。
|
||||
A request to `/api/whoami` should return a JSON object with your preferred language in the `language` key.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -54,7 +60,7 @@ dashedName: request-header-parser-microservice
|
||||
);
|
||||
```
|
||||
|
||||
向 `/api/whoami` 發送請求,返回一個 JSON 對象,這個 JSON 對象應該含有存放(發送請求的)軟件的 `software` 鍵。
|
||||
A request to `/api/whoami` should return a JSON object with your software in the `software` key.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,13 +14,19 @@ dashedName: timestamp-microservice
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-timestamp" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
**注意:** 時區轉換不是本項目的目的,因此假設所有發送的有效日期將使用 `new Date()` 解析爲 GMT 日期。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
**Note:** Time zones conversion is not a purpose of this project, so assume all sent valid dates will be parsed with `new Date()` as GMT dates.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -30,7 +36,7 @@ dashedName: timestamp-microservice
|
||||
};
|
||||
```
|
||||
|
||||
一個對 `/api/:date?` 的有效日期的請求應該返回一個 JSON 對象,該對象的 `unix` 鍵是輸入日期的 Unix 時間戳,單位是毫秒(數字類型)。
|
||||
A request to `/api/:date?` with a valid date should return a JSON object with a `unix` key that is a Unix timestamp of the input date in milliseconds (as type Number)
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +54,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
對具有有效日期的 `/api/:date?` 的請求應返回一個帶有 `utc` 鍵的 JSON 對象,該鍵是輸入日期的字符串,格式爲:`Thu, 01 Jan 1970 00:00:00 GMT`
|
||||
A request to `/api/:date?` with a valid date should return a JSON object with a `utc` key that is a string of the input date in the format: `Thu, 01 Jan 1970 00:00:00 GMT`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -66,7 +72,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
對 `/api/1451001600000` 的請求應該返回 `{ unix: 1451001600000, utc: "Fri, 25 Dec 2015 00:00:00 GMT" }`
|
||||
A request to `/api/1451001600000` should return `{ unix: 1451001600000, utc: "Fri, 25 Dec 2015 00:00:00 GMT" }`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -83,7 +89,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
你的項目可以處理可以通過 `new Date(date_string)` 成功解析的日期
|
||||
Your project can handle dates that can be successfully parsed by `new Date(date_string)`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -100,7 +106,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
如果輸入的日期字符串無效,api 將返回一個具有結構的對象 `{ error : "Invalid Date" }`
|
||||
If the input date string is invalid, the api returns an object having the structure `{ error : "Invalid Date" }`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -114,7 +120,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
一個空的日期參數應該返回一個帶有 `unix` 鍵的 JSON 對象中的當前時間
|
||||
An empty date parameter should return the current time in a JSON object with a `unix` key
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -129,7 +135,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
空日期參數應返回帶有 `utc` 鍵的 JSON 對象中的當前時間
|
||||
An empty date parameter should return the current time in a JSON object with a `utc` key
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,15 +14,21 @@ dashedName: url-shortener-microservice
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-urlshortener" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
**提示:** 請使用 body parsing 中間件來處理 POST 請求, 也可以使用 `dns` 核心模塊中的 `dns.lookup(host, cb)` 函數驗證提交的 URL。
|
||||
**HINT:** Do not forget to use a body parsing middleware to handle the POST requests. Also, you can use the function `dns.lookup(host, cb)` from the `dns` core module to verify a submitted URL.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -34,7 +40,7 @@ dashedName: url-shortener-microservice
|
||||
};
|
||||
```
|
||||
|
||||
可以通過 POST 請求給 `/api/shorturl` 發送一個 URL,並返回一個帶有 `original_url` 和 `short_url` 屬性的 JSON 響應。 例如:`{ original_url : 'https://freeCodeCamp.org', short_url : 1}`。
|
||||
You can POST a URL to `/api/shorturl` and get a JSON response with `original_url` and `short_url` properties. Here's an example: `{ original_url : 'https://freeCodeCamp.org', short_url : 1}`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -56,7 +62,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
當訪問 `/api/shorturl/<short_url>` 時, 將重定向到原來的 URL。
|
||||
When you visit `/api/shorturl/<short_url>`, you will be redirected to the original URL.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -88,7 +94,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果傳入一個沒有遵循如 `http://www.example.com` 的無效 URL,則返回包含 `{ error: 'invalid url' }` 的 JSON 響應。
|
||||
If you pass an invalid URL that doesn't follow the valid `http://www.example.com` format, the JSON response will contain `{ error: 'invalid url' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,21 +14,27 @@ dashedName: meet-the-node-console
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-express" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成這些挑戰。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
在開發過程中,能夠隨時看到代碼的運行結果是非常重要的。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
Node 只是一個 JavaScript 環境。 與客戶端 JavaScript 一樣,你可以使用控制檯顯示有用的調試信息。 在本地計算機上,你可以在終端中輸出調試信息。 在 Replit 上,右側邊欄會默認打開一個終端。
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
我們建議在做這些挑戰題時保持終端打開的狀態。 通過這些終端的輸出,你可能會發現這些錯誤的本質原因。
|
||||
During the development process, it is important to be able to check what’s going on in your code.
|
||||
|
||||
Node is just a JavaScript environment. Like client side JavaScript, you can use the console to display useful debug information. On your local machine, you would see console output in a terminal. On Replit, a terminal is open in the right pane by default.
|
||||
|
||||
We recommend to keep the terminal open while working at these challenges. By reading the output in the terminal, you can see any errors that may occur.
|
||||
|
||||
# --instructions--
|
||||
|
||||
修改 `myApp.js` 文件,在控制檯打印出 “Hello World”。
|
||||
Modify the `myApp.js` file to log "Hello World" to the console.
|
||||
|
||||
# --hints--
|
||||
|
||||
控制檯應該輸出 `"Hello World"`
|
||||
`"Hello World"` should be in the console
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,13 +14,19 @@ dashedName: how-to-use-package-json-the-core-of-any-node-js-project-or-npm-packa
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-npm" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成這些挑戰。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
`package.json` 文件是所有 Node.js 項目和 npm 包的樞紐, 和 HTML 文檔中的 <head> 區域用來描述網頁的配置信息(元數據)一樣,它存儲項目的相關信息。 它由單個 JSON 對象組成,並以鍵值對的形式存儲項目信息, 且至少包含兩個必填字段:“name”和“version”——但是最好提供有關項目的其他信息,這將對用戶或者維護者有所幫助。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
如果能找到項目的文件樹,那麼可以在文件樹的最外層找到 package.json, 在接下來的幾個挑戰中將完善這個文件。
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
在這個文件中最常見的信息之一是 `author` 字段, 它說明了項目的創建者,它可以是字符串,也可以是帶有聯繫人詳細信息的對象。 對於較大的項目,建議使用對象;但是在我們的項目中,一個簡單的字符串就夠了,比如下面的例子:
|
||||
The `package.json` file is the center of any Node.js project or npm package. It stores information about your project, similar to how the <head> section of an HTML document describes the content of a webpage. It consists of a single JSON object where information is stored in key-value pairs. There are only two required fields; "name" and "version", but it’s good practice to provide additional information about your project that could be useful to future users or maintainers.
|
||||
|
||||
If you look at the file tree of your project, you will find the package.json file on the top level of the tree. This is the file that you will be improving in the next couple of challenges.
|
||||
|
||||
One of the most common pieces of information in this file is the `author` field. It specifies who created the project, and can consist of a string or an object with contact or other details. An object is recommended for bigger projects, but a simple string like the following example will do for this project.
|
||||
|
||||
```json
|
||||
"author": "Jane Doe",
|
||||
@@ -28,13 +34,13 @@ dashedName: how-to-use-package-json-the-core-of-any-node-js-project-or-npm-packa
|
||||
|
||||
# --instructions--
|
||||
|
||||
在項目的 package.json 文件的 `author` 鍵中添加你的名字。
|
||||
Add your name as the `author` of the project in the package.json file.
|
||||
|
||||
**注意:** 正在修改的是一個 JSON,所有的字段名必須用雙引號(")包裹,也必須用逗號(,)分割。
|
||||
**Note:** Remember that you’re writing JSON, so all field names must use double-quotes (") and be separated with a comma (,).
|
||||
|
||||
# --hints--
|
||||
|
||||
package.json 應該有一個有效的“author”鍵
|
||||
package.json should have a valid "author" key
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,19 +14,25 @@ dashedName: install-and-set-up-mongoose
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-mongomongoose" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成這些挑戰。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
在這個挑戰中,你將建立一個 MongoDB Atlas 數據庫並導入連接到它所需的軟件包。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
按照<a href='https://chinese.freecodecamp.org/news/get-started-with-mongodb-atlas/' target="_blank" rel="noopener noreferrer nofollow">這篇教程</a>在 MongoDB Atlas 創建一個託管數據庫。
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
In this challenge, you will set up a MongoDB Atlas database and import the required packages to connect to it.
|
||||
|
||||
Follow <a href='https://www.freecodecamp.org/news/get-started-with-mongodb-atlas/' target="_blank" rel="noopener noreferrer nofollow">this tutorial</a> to set up a hosted database on MongoDB Atlas.
|
||||
|
||||
# --instructions--
|
||||
|
||||
`mongoose@^5.11.15` 已添加到你項目的 `package.json` 文件中。 首先,在 `myApp.js` 中請求 mongoose 爲 `mongoose`。 接下來,創建一個 `.env` 文件並向其中添加一個 `MONGO_URI` 變量。 變量的值爲你的 MongoDB Atlas 數據庫 URI。 應用單引號或雙引號包裹 URI。請記住,環境變量 `=` 兩邊不能有空格。 例如,`MONGO_URI='VALUE'`。
|
||||
`mongoose@^5.11.15` has been added to your project’s `package.json` file. First, require mongoose as `mongoose` in `myApp.js`. Next, create a `.env` file and add a `MONGO_URI` variable to it. Its value should be your MongoDB Atlas database URI. Be sure to surround the URI with single or double quotes, and remember that you can't use spaces around the `=` in environment variables. For example, `MONGO_URI='VALUE'`.
|
||||
|
||||
**注意:** 如果你使用的是 Replit,則無法創建 `.env` 文件。 相反,使用內置的 <dfn>SECRETS</dfn> 選項卡來添加變量。 在使用 <em>SECRETS</em> 選項卡時,<em>不要</em>將值括在引號中。
|
||||
**Note:** If you are using Replit, you cannot create a `.env` file. Instead, use the built-in <dfn>SECRETS</dfn> tab to add the variable. <em>Do not</em> surround the values with quotes when using the <em>SECRETS</em> tab.
|
||||
|
||||
完成後,使用以下語法連接到數據庫:
|
||||
When you are done, connect to the database using the following syntax:
|
||||
|
||||
```js
|
||||
mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true });
|
||||
@@ -34,7 +40,7 @@ mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true }
|
||||
|
||||
# --hints--
|
||||
|
||||
“mongoose version ^5.11.15” 依賴項應該在 package.json
|
||||
"mongoose version ^5.11.15" dependency should be in package.json
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -54,7 +60,7 @@ mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true }
|
||||
);
|
||||
```
|
||||
|
||||
應使用 “mongoose” 連接數據庫。
|
||||
"mongoose" should be connected to a database
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,13 +14,19 @@ dashedName: set-up-a-template-engine
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-advancednode" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成這些挑戰。
|
||||
- 使用一個你選擇的站點生成器來完成項目。 需要確定包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 框中提交你的項目 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
你可以在應用的模版引擎中使用靜態模板文件(如那些寫在 *Pug* 裏的)。 在運行時,模版引擎會用服務端的真實數據替換掉模版文件中的變量, 然後將模版轉譯成發送給客戶端的 HTML 靜態文件。 這樣可以輕鬆地構造 HTML 頁面,允許在頁面直接顯示變量內容而不需要從客戶端發送 API 請求。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
`pug@~3.0.0` 已經被安裝,並且在你項目的 `package.json` 文件中作爲依賴。
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
Express 需要知道你正在使用哪個模板引擎。 Use the `set` method to assign `pug` as the `view engine` property's value:
|
||||
A template engine enables you to use static template files (such as those written in *Pug*) in your app. At runtime, the template engine replaces variables in a template file with actual values which can be supplied by your server. Then it transforms the template into a static HTML file that is sent to the client. This approach makes it easier to design an HTML page and allows for displaying variables on the page without needing to make an API call from the client.
|
||||
|
||||
`pug@~3.0.0` has already been installed, and is listed as a dependency in your `package.json` file.
|
||||
|
||||
Express needs to know which template engine you are using. Use the `set` method to assign `pug` as the `view engine` property's value:
|
||||
|
||||
```javascript
|
||||
app.set('view engine', 'pug');
|
||||
@@ -32,11 +38,11 @@ Finally, use `res.render()` in the route for your home page, passing `index` as
|
||||
|
||||
If all went as planned, your app home page will no longer be blank. Instead, it will display a message indicating you've successfully rendered the Pug template!
|
||||
|
||||
完成以上要求後,請提交你的頁面鏈接。 If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#set-up-a-template-engine-1" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
|
||||
Submit your page when you think you've got it right. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#set-up-a-template-engine-1" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
|
||||
|
||||
# --hints--
|
||||
|
||||
項目中應使用 Pug 作爲依賴。
|
||||
Pug should be a dependency.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -51,7 +57,7 @@ async (getUserInput) => {
|
||||
}
|
||||
```
|
||||
|
||||
View 引擎應該是 Pug。
|
||||
View engine should be Pug.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,15 +14,21 @@ dashedName: learn-how-javascript-assertions-work
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-mochachai" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成這些挑戰。
|
||||
- 使用一個你喜歡的站點生成器來完成項目。 需要確定包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 框中提交你的項目 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
在 `tests/1_unit-tests.js` 文件下 `Basic Assertions` suite 內註釋爲 `#1` 的地方,將每一個 `assert` 更改爲 `assert.isNull` 或 `assert.isNotNull` 以使測試通過(應該返回 `true`)。 不要改變傳入斷言的參數。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#1` in the `Basic Assertions` suite, change each `assert` to either `assert.isNull` or `assert.isNotNull` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
所有測試都應該通過。
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -36,7 +42,7 @@ dashedName: learn-how-javascript-assertions-work
|
||||
);
|
||||
```
|
||||
|
||||
請爲第一個斷言選擇正確的方法— `isNull` 或 `isNotNull`。
|
||||
You should choose the correct method for the first assertion - `isNull` vs. `isNotNull`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +56,7 @@ dashedName: learn-how-javascript-assertions-work
|
||||
);
|
||||
```
|
||||
|
||||
請爲第二個斷言選擇正確的方法— `isNull` 或 `isNotNull`。
|
||||
You should choose the correct method for the second assertion - `isNull` vs. `isNotNull`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,56 +14,62 @@ dashedName: american-british-translator
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-american-british-english-translator" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用您選擇的站點生成器來完成項目。 並確保包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
當完成本項目,請確認有一個可以公開訪問的正常運行 demo 。 然後將 URL 提交到 `Solution Link` 中。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
- 所有邏輯都可以進入 `/components/translator.js`
|
||||
- 在 `/routes/api.js` 中完成 `/api/translate` 路由
|
||||
- 在 `tests/1_unit-tests.js` 和 `tests/2_functional-tests.js` 中創建所有 unit/functional 測試
|
||||
- 查看 `/components` 中的 JavaScript 文件以獲取應用程序應該翻譯的條款以及不同的拼寫
|
||||
- 在 `.env` 文件中將 `NODE_ENV` 設置爲 `test`(沒有引號),在 Replit 上運行測試。
|
||||
- 使用 `npm run test` 命令,在 console 運行測試。 按 Ctrl+Shift+P(在 Mac 上是 Cmd+Shift+P),並輸入“open shell”,打開 Replit 控制檯。
|
||||
- All logic can go into `/components/translator.js`
|
||||
- Complete the `/api/translate` route in `/routes/api.js`
|
||||
- Create all of the unit/functional tests in `tests/1_unit-tests.js` and `tests/2_functional-tests.js`
|
||||
- See the JavaScript files in `/components` for the different spelling and terms your application should translate
|
||||
- To run the tests on Replit, set `NODE_ENV` to `test` without quotes in the `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Replit console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
|
||||
在 `tests/1_unit-tests.js` 中寫下以下測試:
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
|
||||
- 將 `Mangoes are my favorite fruit.` 轉換成英式英語。
|
||||
- 將 `I ate yogurt for breakfast.` 轉換成英式英語。
|
||||
- 將 `We had a party at my friend's condo.` 轉換成英式英語。
|
||||
- 將 `Can you toss this in the trashcan for me?` 轉換成英式英語。
|
||||
- 將 `The parking lot was full.` 轉換成英式英語。
|
||||
- 將 `Like a high tech Rube Goldberg machine.` 轉換成英式英語。
|
||||
- 將 `To play hooky means to skip class or work.` 轉換成英式英語。
|
||||
- 將 `No Mr. Bond, I expect you to die.` 轉換成英式英語。
|
||||
- 將 `Dr. Grosh will see you now.` 轉換成英式英語。
|
||||
- 將 `Lunch is at 12:15 today.` 轉換成英式英語。
|
||||
- 將 `We watched the footie match for a while.` 轉換成美式英語。
|
||||
- 將 `Paracetamol takes up to an hour to work.` 轉換成美式英語。
|
||||
- 將 `First, caramelise the onions.` 轉換成美式英語。
|
||||
- 將 `I spent the bank holiday at the funfair.` 轉換成美式英語。
|
||||
- 將 `I had a bicky then went to the chippy.` 轉換成美式英語。
|
||||
- 將 `I've just got bits and bobs in my bum bag.` 轉換成美式英語。
|
||||
- 將 `The car boot sale at Boxted Airfield was called off.` 轉換成美式英語。
|
||||
- 將 `Have you met Mrs Kalyani?` 轉換成美式英語。
|
||||
- 將 `Prof Joyner of King's College, London.` 轉換成美式英語。
|
||||
- 將 `Tea time is usually around 4 or 4.30.` 轉換成美式英語。
|
||||
- 將 `Mangoes are my favorite fruit.` 裏的轉換高亮。
|
||||
- 高亮 `I ate yogurt for breakfast.` 裏的轉換。
|
||||
- 高亮 `We watched the footie match for a while.` 裏的轉換。
|
||||
- 高亮 `Paracetamol takes up to an hour to work.` 裏的轉換。
|
||||
- Translate `Mangoes are my favorite fruit.` to British English
|
||||
- Translate `I ate yogurt for breakfast.` to British English
|
||||
- Translate `We had a party at my friend's condo.` to British English
|
||||
- Translate `Can you toss this in the trashcan for me?` to British English
|
||||
- Translate `The parking lot was full.` to British English
|
||||
- Translate `Like a high tech Rube Goldberg machine.` to British English
|
||||
- Translate `To play hooky means to skip class or work.` to British English
|
||||
- Translate `No Mr. Bond, I expect you to die.` to British English
|
||||
- Translate `Dr. Grosh will see you now.` to British English
|
||||
- Translate `Lunch is at 12:15 today.` to British English
|
||||
- Translate `We watched the footie match for a while.` to American English
|
||||
- Translate `Paracetamol takes up to an hour to work.` to American English
|
||||
- Translate `First, caramelise the onions.` to American English
|
||||
- Translate `I spent the bank holiday at the funfair.` to American English
|
||||
- Translate `I had a bicky then went to the chippy.` to American English
|
||||
- Translate `I've just got bits and bobs in my bum bag.` to American English
|
||||
- Translate `The car boot sale at Boxted Airfield was called off.` to American English
|
||||
- Translate `Have you met Mrs Kalyani?` to American English
|
||||
- Translate `Prof Joyner of King's College, London.` to American English
|
||||
- Translate `Tea time is usually around 4 or 4.30.` to American English
|
||||
- Highlight translation in `Mangoes are my favorite fruit.`
|
||||
- Highlight translation in `I ate yogurt for breakfast.`
|
||||
- Highlight translation in `We watched the footie match for a while.`
|
||||
- Highlight translation in `Paracetamol takes up to an hour to work.`
|
||||
|
||||
在 `tests/2_functional-tests.js` 中寫下以下測試:
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
|
||||
- 翻譯文本字段和本地化字段: POST 請求到 `/api/translate`
|
||||
- 翻譯文本字段和無效的本地化字段: POST 請求到 `/api/translate`
|
||||
- 翻譯缺失的文本字段: POST 請求到 `/api/translate`
|
||||
- 翻譯缺失的本地化字段: POST 請求到 `/api/translate`
|
||||
- 翻譯空的文本: POST 請求到 `/api/translate`
|
||||
- 翻譯無需翻譯的文本: POST 請求到 `/api/translate`
|
||||
- Translation with text and locale fields: POST request to `/api/translate`
|
||||
- Translation with text and invalid locale field: POST request to `/api/translate`
|
||||
- Translation with missing text field: POST request to `/api/translate`
|
||||
- Translation with missing locale field: POST request to `/api/translate`
|
||||
- Translation with empty text: POST request to `/api/translate`
|
||||
- Translation with text that needs no translation: POST request to `/api/translate`
|
||||
|
||||
# --hints--
|
||||
|
||||
我可以提供我自己的項目,而不是示例 URL。
|
||||
I can provide my own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -75,7 +81,7 @@ dashedName: american-british-translator
|
||||
};
|
||||
```
|
||||
|
||||
可以向 `/api/translate` 發送 `POST` 請求,對請求體內的 `text` 文本進行翻譯, `locale` 字段可以是 `american-to-british` 或 `british-to-american`。 返回的對象應該包含提交的 `text` 以及翻譯的文本 `translation`。
|
||||
You can `POST` to `/api/translate` with a body containing `text` with the text to translate and `locale` with either `american-to-british` or `british-to-american`. The returned object should contain the submitted `text` and `translation` with the translated text.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -103,7 +109,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`/api/translate` 路由應該可以處理用英美方式英語寫的時間。 例如,十點半英式英語寫爲“10.30”,而美式英語寫爲“10:30”。 `span` 元素應該包裹整個時間字符串,即 `<span class="highlight">10:30</span>`。
|
||||
The `/api/translate` route should handle the way time is written in American and British English. For example, ten thirty is written as "10.30" in British English and "10:30" in American English. The `span` element should wrap the entire time string, i.e. `<span class="highlight">10:30</span>`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -130,7 +136,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`/api/translate` 路由也應該處理美式英語和英式英語中頭銜/尊稱的縮寫方式。 例如,Doctor Wright 在英式英語中縮寫爲 “Dr Wright”,在美式英語中縮寫爲 “Dr. Wright"”。 請參閱 `/components/american-to-british-titles.js`,瞭解程序應當處理的不同標題。
|
||||
The `/api/translate` route should also handle the way titles/honorifics are abbreviated in American and British English. For example, Doctor Wright is abbreviated as "Dr Wright" in British English and "Dr. Wright" in American English. See `/components/american-to-british-titles.js` for the different titles your application should handle.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -157,7 +163,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
將任何翻譯過的拼寫或條目放在 `<span class="highlight">...</span>` 標籤內以使其顯示爲綠色。
|
||||
Wrap any translated spelling or terms with `<span class="highlight">...</span>` tags so they appear in green.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -185,7 +191,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果缺少一個或多個必填字段,返回 `{ error: 'Required field(s) missing' }`。
|
||||
If one or more of the required fields is missing, return `{ error: 'Required field(s) missing' }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -206,7 +212,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果 `text` 爲空,返回 `{ error: 'No text to translate' }`
|
||||
If `text` is empty, return `{ error: 'No text to translate' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -227,7 +233,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果 `locale` 與兩個指定的 locales 都不匹配,返回 `{ error: 'Invalid value for locale field' }`。
|
||||
If `locale` does not match one of the two specified locales, return `{ error: 'Invalid value for locale field' }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -249,7 +255,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果 `text` 不需要翻譯,返回的 `translation` 值爲`"Everything looks good to me!"`。
|
||||
If `text` requires no translation, return `"Everything looks good to me!"` for the `translation` value.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -276,7 +282,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 24 個單元的測試都已完成並通過。 請參閱 `/tests/1_unit-tests.js` 來了解你應該寫的測試的預期行爲。
|
||||
All 24 unit tests are complete and passing. See `/tests/1_unit-tests.js` for the expected behavior you should write tests for.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -301,7 +307,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 6 項功能測試都已完成並通過。 請參閱 `/tests/2_functional-tests.js` 來了解你應該寫的測試的功能。
|
||||
All 6 functional tests are complete and passing. See `/tests/2_functional-tests.js` for the functionality you should write tests for.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,36 +14,42 @@ dashedName: issue-tracker
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-issuetracker" target="_blank" rel="noopener noreferrer nofollow">我們的 Replit 初始化項目</a>來完成你的項目。
|
||||
- 使用一個你喜歡的站點生成器來完成項目。 需要確定包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 框中提交你的項目 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
- 在 `/routes/api.js` 中完成必要的路由
|
||||
- 在 `tests/2_functional-tests.js` 中創建所有的功能測試
|
||||
- 複製 `sample.env` 文件到 `.env` 並按需設置變量
|
||||
- 要運行測試,在 `.env` 文件中取消註釋 `NODE_ENV=test`
|
||||
- 使用 `npm run test` 命令,在 console 運行測試。 按 Ctrl+Shift+P(在 Mac 上是 Cmd+Shift+P),並輸入“open shell”,打開 Replit 控制檯。
|
||||
- Complete the necessary routes in `/routes/api.js`
|
||||
- Create all of the functional tests in `tests/2_functional-tests.js`
|
||||
- Copy the `sample.env` file to `.env` and set the variables appropriately
|
||||
- To run the tests uncomment `NODE_ENV=test` in your `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Replit console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
|
||||
在 `tests/2_functional-tests.js` 中編寫下以下測試:
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
|
||||
- 用所有字段創建 issue:POST 請求到 `/api/issues/{project}`
|
||||
- 用必填字段創建 issue:POST 請求到 `/api/issues/{project}`
|
||||
- 用缺失必填字段創建 issue:POST 請求到 `/api/issues/{project}`
|
||||
- 查看 project 裏的 issue:GET 請求到 `/api/issues/{project}`
|
||||
- 用 filter 過濾 project 裏的 issue:GET 請求到 `/api/issues/{project}`
|
||||
- 用多個 filter 過濾 project 裏的 issue:GET 請求到 `/api/issues/{project}`
|
||||
- 更新 issue 裏的一個字段:PUT 請求到 `/api/issues/{project}`
|
||||
- 更新 issue 裏的多個字段:PUT 請求到 `/api/issues/{project}`
|
||||
- 在缺少 `_id` 字段的情況下更新 issue: PUT 請求到 `/api/issues/{project}`
|
||||
- 在沒有字段更新的情況下調用更新:PUT 請求到 `/api/issues/{project}`
|
||||
- 傳入一個無效的的 `_id` 來調用更新:PUT 請求到 `/api/issues/{project}`
|
||||
- 刪除一個 issue:DELETE 請求到 `/api/issues/{project}`
|
||||
- 傳入一個無效的的 `_id` 來調用刪除:DELETE 請求到 `/api/issues/{project}`
|
||||
- 在缺失 `_id` 的情況下來調用刪除:DELETE 請求到 `/api/issues/{project}`
|
||||
- Create an issue with every field: POST request to `/api/issues/{project}`
|
||||
- Create an issue with only required fields: POST request to `/api/issues/{project}`
|
||||
- Create an issue with missing required fields: POST request to `/api/issues/{project}`
|
||||
- View issues on a project: GET request to `/api/issues/{project}`
|
||||
- View issues on a project with one filter: GET request to `/api/issues/{project}`
|
||||
- View issues on a project with multiple filters: GET request to `/api/issues/{project}`
|
||||
- Update one field on an issue: PUT request to `/api/issues/{project}`
|
||||
- Update multiple fields on an issue: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with missing `_id`: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with no fields to update: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with an invalid `_id`: PUT request to `/api/issues/{project}`
|
||||
- Delete an issue: DELETE request to `/api/issues/{project}`
|
||||
- Delete an issue with an invalid `_id`: DELETE request to `/api/issues/{project}`
|
||||
- Delete an issue with missing `_id`: DELETE request to `/api/issues/{project}`
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -51,7 +57,7 @@ dashedName: issue-tracker
|
||||
};
|
||||
```
|
||||
|
||||
可以發送 `POST` 請求到 `/api/issues/{projectname}`,表單數據包含必填字段 `issue_title`、`issue_text`、`created_by` 和可選字段 `assigned_to` 以及 `status_text`。
|
||||
You can send a `POST` request to `/api/issues/{projectname}` with form data containing the required fields `issue_title`, `issue_text`, `created_by`, and optionally `assigned_to` and `status_text`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -73,7 +79,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`POST` 請求到 `/api/issues/{projectname}` 將返回創建的對象,必須包含所有提交的全部字段。 如果沒有填選填字段將作爲空字符串返回. 此外,包含 `created_on` (日期/時間)、 `updated_on` (日期/時間)、 `open` (布爾型) `true` 用於打開 - 默認值, `false` 用於關閉, `_id`。
|
||||
The `POST` request to `/api/issues/{projectname}` will return the created object, and must include all of the submitted fields. Excluded optional fields will be returned as empty strings. Additionally, include `created_on` (date/time), `updated_on` (date/time), `open` (boolean, `true` for open - default value, `false` for closed), and `_id`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -107,7 +113,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果發送一個 `POST` 請求到 `/api/issues/{projectname}` 且缺少必填字段,會返回錯誤 `{ error: 'required field(s) missing' }`。
|
||||
If you send a `POST` request to `/api/issues/{projectname}` without the required fields, returned will be the error `{ error: 'required field(s) missing' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -125,7 +131,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以發送 `GET` 請求到 `/api/issues/{projectname}` 請求所有指定 `projectname` 的 issues 數組,會展示每個 issue 的所有字段。
|
||||
You can send a `GET` request to `/api/issues/{projectname}` for an array of all issues for that specific `projectname`, with all the fields present for each issue.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -172,7 +178,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以發送 `GET` 請求到 `/api/issues/{projectname}` 通過 URL 查詢傳入字段名和值過濾請求(如, `/api/issues/{project}?open=false`)。 你可以一次通過一個或多個字段/值對。
|
||||
You can send a `GET` request to `/api/issues/{projectname}` and filter the request by also passing along any field and value as a URL query (ie. `/api/issues/{project}?open=false`). You can pass one or more field/value pairs at once.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -213,7 +219,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以發送一個 `PUT` 請求到 `/api/issues/{projectname}` 帶有一個 `_id` 以及一個或多個字段進行更新。 成功後, `updated_on` field 應該被更新,返回的應該是 `{ result: 'successfully updated', '_id': _id }`。
|
||||
You can send a `PUT` request to `/api/issues/{projectname}` with an `_id` and one or more fields to update. On success, the `updated_on` field should be updated, and returned should be `{ result: 'successfully updated', '_id': _id }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -248,7 +254,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
當 `PUT` 請求發送給 `/api/issues/{projectname}` 的請求體不包含 `_id` 時應返回`{ error: 'missing _id' }`。
|
||||
When the `PUT` request sent to `/api/issues/{projectname}` does not include an `_id`, the return value is `{ error: 'missing _id' }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -264,7 +270,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
當 `PUT` 請求發送給 `/api/issues/{projectname}` 的請求體不包含任何更新的字段,應返回 `{ error: 'no update field(s) sent', '_id': _id }`。 在任何其他錯誤,應返回 `{ error: 'could not update', '_id': _id }`。
|
||||
When the `PUT` request sent to `/api/issues/{projectname}` does not include update fields, the return value is `{ error: 'no update field(s) sent', '_id': _id }`. On any other error, the return value is `{ error: 'could not update', '_id': _id }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -294,7 +300,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以發送一個 `DELETE` 請求到 `/api/issues/{projectname}` 帶有一個 `_id` 來刪除 issue。 如果沒有發送 `_id` ,返回值爲 `{ error: 'missing _id' }`。 成功後,返回值爲 `{ result: 'successfully deleted', '_id': _id }`。 失敗時,返回值爲 `{ error: 'could not delete', '_id': _id }`。
|
||||
You can send a `DELETE` request to `/api/issues/{projectname}` with an `_id` to delete an issue. If no `_id` is sent, the return value is `{ error: 'missing _id' }`. On success, the return value is `{ result: 'successfully deleted', '_id': _id }`. On failure, the return value is `{ error: 'could not delete', '_id': _id }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -336,7 +342,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 14 項功能測試都已完成並通過。
|
||||
All 14 functional tests are complete and passing.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,46 +14,52 @@ dashedName: metric-imperial-converter
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-metricimpconverter" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用一個你喜歡的站點生成器來完成項目。 需要確定包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 框中提交你的項目 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
- 在 `/controllers/convertHandler.js` 中完成必要的轉換邏輯
|
||||
- 在 `/routes/api.js` 中完成必要的路由
|
||||
- 複製 `sample.env` 文件到 `.env` 並按需設置變量
|
||||
- 在 `.env` 文件中取消註釋 `NODE_ENV=test` 來運行測試
|
||||
- 使用 `npm run test` 命令在 console 中運行測試。 按 Ctrl+Shift+P(在 Mac 上是 Cmd+Shift+P),並輸入“open shell”,打開 Replit 控制檯。
|
||||
- Complete the necessary conversion logic in `/controllers/convertHandler.js`
|
||||
- Complete the necessary routes in `/routes/api.js`
|
||||
- Copy the `sample.env` file to `.env` and set the variables appropriately
|
||||
- To run the tests uncomment `NODE_ENV=test` in your `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Replit console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
|
||||
在 `tests/1_unit-tests.js` 中寫下以下測試:
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
|
||||
- `convertHandler` 應該正確地讀取整個數字輸入。
|
||||
- `convertHandler` 應該正確地讀取十進制數字輸入。
|
||||
- `convertHandler` 應該正確地讀取一個分數輸入。
|
||||
- `convertHandler` 應該正確地讀取一個帶小數點的分數輸入。
|
||||
- `convertHandler` 當輸入雙分數時應該返回錯誤 ( `3/2/3`)。
|
||||
- `convertHandler` 在沒有提供數字輸入時應該默認爲 `1`。
|
||||
- `convertHandler` 應該正確地讀取每個有效的單位輸入。
|
||||
- `convertHandler` 在輸入無效單位時應返回錯誤。
|
||||
- `convertHandler` 在輸入有效單位時應返回正確的單位。
|
||||
- `convertHandler` 應該正確返回每個有效輸入單位的拼寫字符串。
|
||||
- `convertHandler` 應該正確地將 `gal` 轉換爲 `L`。
|
||||
- `convertHandler` 應該正確地將 `L` 轉換爲 `gal`。
|
||||
- `convertHandler` 應該正確地將 `mi` 轉換爲 `km`。
|
||||
- `convertHandler` 應該正確地將 `km` 轉換爲 `mi`。
|
||||
- `convertHandler` 應該正確地將 `lbs` 轉換爲 `kg`。
|
||||
- `convertHandler` 應該正確地將 `kg` 轉換爲 `lbs`。
|
||||
- `convertHandler` should correctly read a whole number input.
|
||||
- `convertHandler` should correctly read a decimal number input.
|
||||
- `convertHandler` should correctly read a fractional input.
|
||||
- `convertHandler` should correctly read a fractional input with a decimal.
|
||||
- `convertHandler` should correctly return an error on a double-fraction (i.e. `3/2/3`).
|
||||
- `convertHandler` should correctly default to a numerical input of `1` when no numerical input is provided.
|
||||
- `convertHandler` should correctly read each valid input unit.
|
||||
- `convertHandler` should correctly return an error for an invalid input unit.
|
||||
- `convertHandler` should return the correct return unit for each valid input unit.
|
||||
- `convertHandler` should correctly return the spelled-out string unit for each valid input unit.
|
||||
- `convertHandler` should correctly convert `gal` to `L`.
|
||||
- `convertHandler` should correctly convert `L` to `gal`.
|
||||
- `convertHandler` should correctly convert `mi` to `km`.
|
||||
- `convertHandler` should correctly convert `km` to `mi`.
|
||||
- `convertHandler` should correctly convert `lbs` to `kg`.
|
||||
- `convertHandler` should correctly convert `kg` to `lbs`.
|
||||
|
||||
在 `tests/2_functional-tests.js` 中寫下以下測試:
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
|
||||
- 將有效的輸入轉換爲 `10L`: `GET` 請求到 `/api/convert`。
|
||||
- 轉換無效的輸如 `32g`: `GET` 請求到 `/api/convert`.
|
||||
- 轉換無效的數字,例如 `3/7.2/4kg`: `GET` 請求到 `/api/convert`。
|
||||
- 轉換無效的數字和單位如 `3/7.2/4kilomegagram`: `GET` 請求到 `/api/convert`.
|
||||
- 轉換時沒有數字,例如 `kg`: `GET` 請求到 `/api/convert`。
|
||||
- Convert a valid input such as `10L`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid input such as `32g`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid number such as `3/7.2/4kg`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid number AND unit such as `3/7.2/4kilomegagram`: `GET` request to `/api/convert`.
|
||||
- Convert with no number such as `kg`: `GET` request to `/api/convert`.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
getUserInput => {
|
||||
@@ -65,13 +71,13 @@ getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
通過 `GET` 請求 `/api/convert`,傳入數字和單位的單個參數,可以將其轉換。 (提示:通過尋找第一個字符的索引來分割輸入,這將標記單位的開始)
|
||||
You can `GET` `/api/convert` with a single parameter containing an accepted number and unit and have it converted. (Hint: Split the input by looking for the index of the first character which will mark the start of the unit)
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
可以將 `'gal'` 轉換爲 `'L'`,反之亦然。 (1 gal to 3.78541 L)
|
||||
You can convert `'gal'` to `'L'` and vice versa. (1 gal to 3.78541 L)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -94,7 +100,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
可以將 `'lbs'` 轉換爲 `'kg'`,反之亦然。 (1 lbs to 0.453592 kg)
|
||||
You can convert `'lbs'` to `'kg'` and vice versa. (1 lbs to 0.453592 kg)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -117,7 +123,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以將 `'mi'` 轉換爲 `'km'` 反之亦然。 (1 mi to 1.60934 km)
|
||||
You can convert `'mi'` to `'km'` and vice versa. (1 mi to 1.60934 km)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -140,7 +146,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
所有輸入單位以大寫和小寫形式都應該被接受,但在 `initUnit` 和 `returnUnit` 中應以小寫形式返回,升除外,應將其表示爲大寫的 `'L'`。
|
||||
All incoming units should be accepted in both upper and lower case, but should be returned in both the `initUnit` and `returnUnit` in lower case, except for liter, which should be represented as an uppercase `'L'`.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -163,7 +169,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
如果測量單位無效,返回將爲 `'invalid unit'`。
|
||||
If the unit of measurement is invalid, returned will be `'invalid unit'`.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -176,7 +182,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
如果數字無效,返回將爲 `'invalid number'`。
|
||||
If the number is invalid, returned will be `'invalid number'`.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -191,7 +197,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
如果單位和數字都無效,返回將爲 `'invalid number and unit'`。
|
||||
If both the unit and number are invalid, returned will be `'invalid number and unit'`.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -209,7 +215,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
可以在參數中使用分數、小數或小數分數 (例如 5, 1/2, 2.5/6),如果沒有提供任何內容,則默認值爲 1。
|
||||
You can use fractions, decimals or both in the parameter (ie. 5, 1/2, 2.5/6), but if nothing is provided it will default to 1.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -240,7 +246,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
返回將包含 `initNum`、`initUnit`、`returnNum`、`returnUnit` 和 `string` 拼寫單位格式 `'{initNum} {initUnitString} converts to {returnNum} {returnUnitString}'` 結果四捨五入爲 5 小數。
|
||||
Your return will consist of the `initNum`, `initUnit`, `returnNum`, `returnUnit`, and `string` spelling out units in the format `'{initNum} {initUnitString} converts to {returnNum} {returnUnitString}'` with the result rounded to 5 decimals.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -257,7 +263,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 16 個單元的測試都已完成並通過。
|
||||
All 16 unit tests are complete and passing.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -282,7 +288,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 5 項功能測試都已完成並通過。
|
||||
All 5 functional tests are complete and passing.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
|
||||
@@ -14,7 +14,13 @@ dashedName: personal-library
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-library" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目
|
||||
- 使用一個你喜歡的站點生成器來完成項目。 需要確定包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 框中提交你的項目 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -25,7 +31,7 @@ dashedName: personal-library
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -35,7 +41,7 @@ dashedName: personal-library
|
||||
};
|
||||
```
|
||||
|
||||
可以發送 <b>POST</b> 請求到 `/api/books`,帶有 `title` 作爲表單數據的一部分,來添加一本書。 返回的響應將是一個包含 `title` 和唯一的 `_id` 作爲鍵的對象。 如果 `title` 未包含在請求中,返回的響應應該是字符串 `missing required field title`。
|
||||
You can send a <b>POST</b> request to `/api/books` with `title` as part of the form data to add a book. The returned response will be an object with the `title` and a unique `_id` as keys. If `title` is not included in the request, the returned response should be the string `missing required field title`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -56,7 +62,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以向 `/api/books` 發送 <b>GET</b> 請求,並返回代表所有書的 JSON 響應。 JSON 響應應該是一個包含有 `title`、`_id` 和 `commentcount` 屬性的對象數組 。
|
||||
You can send a <b>GET</b> request to `/api/books` and receive a JSON response representing all the books. The JSON response will be an array of objects with each object (book) containing `title`, `_id`, and `commentcount` properties.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -84,7 +90,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以發送 <b>GET</b> 請求到 `/api/books/{_id}` 來檢索一本書的單個對象,返回屬性 `title`、`_id` 和 `comments` 數組 (如果沒有評論,則展示空數組)。 如果找不到書, 返回字符串 `no book exists`。
|
||||
You can send a <b>GET</b> request to `/api/books/{_id}` to retrieve a single object of a book containing the properties `title`, `_id`, and a `comments` array (empty array if no comments present). If no book is found, return the string `no book exists`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -108,7 +114,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以發送一個 <b>POST</b> 請求,其中包含 `comment` 作爲表單正文數據,請求到 `/api/books/{_id}` 以便將評論添加到書中。 返回的響應將是書對象,在先前測試中 <b>GET</b> `/api/books/{_id}` 類似。 如果請求中沒有包含 `comment` ,返回字符串 `missing required field comment`。 如果找不到書, 返回字符串 `no book exists`。
|
||||
You can send a <b>POST</b> request containing `comment` as the form body data to `/api/books/{_id}` to add a comment to a book. The returned response will be the books object similar to <b>GET</b> `/api/books/{_id}` request in an earlier test. If `comment` is not included in the request, return the string `missing required field comment`. If no book is found, return the string `no book exists`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -146,7 +152,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以向 `/api/books/{_id}` 發送 <b>DELETE</b> 請求,從收藏中刪除一本書。 如果成功,返回的響應將是字符串 `delete successful`。 如果找不到書, 返回字符串 `no book exists`。
|
||||
You can send a <b>DELETE</b> request to `/api/books/{_id}` to delete a book from the collection. The returned response will be the string `delete successful` if successful. If no book is found, return the string `no book exists`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -170,7 +176,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以向 `/api/books` 發送 <b>DELETE</b> 請求來刪除數據庫中的所有書籍。 The returned response will be the string `complete delete successful` if successful.
|
||||
You can send a <b>DELETE</b> request to `/api/books` to delete all books in the database. The returned response will be the string `complete delete successful` if successful.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -187,7 +193,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 10 項功能測試都已完成並通過。
|
||||
All 10 functional tests required are complete and passing.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,54 +14,60 @@ dashedName: sudoku-solver
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-sudoku-solver" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用一個你喜歡的站點生成器來完成項目。 需要確定包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 框中提交你的項目 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
- 所有解謎邏輯都可以進入 `/controllers/sudoku-solver.js`
|
||||
- `validate` 函數應該使用給定的解謎字符串,然後檢查它是否是 81 個有效的輸入字符。
|
||||
- `check` 函數應對棋盤的 *current* 進行驗證。
|
||||
- `solve` 函數應該處理任何給定的解謎字符串,而不僅僅是測試輸入和解決方法。 你需要寫出解決這個問題的邏輯。
|
||||
- 所有路由邏輯都可以進入 `/routes/api.js`
|
||||
- 閱讀 `/controllers` 中的 `puzzle-strings.js` 文件來了解一些應用程序應該解決的示例謎題
|
||||
- 在 `.env` 文件中將 `NODE_ENV` 設置爲 `test` (沒有引號),運行這個頁面的挑戰測試。
|
||||
- 使用 `npm run test` 命令在 console 中運行測試。 按 Ctrl+Shift+P(在 Mac 上是 Cmd+Shift+P),並輸入“open shell”,打開 Replit 控制檯。
|
||||
- All puzzle logic can go into `/controllers/sudoku-solver.js`
|
||||
- The `validate` function should take a given puzzle string and check it to see if it has 81 valid characters for the input.
|
||||
- The `check` functions should be validating against the *current* state of the board.
|
||||
- The `solve` function should handle solving any given valid puzzle string, not just the test inputs and solutions. You are expected to write out the logic to solve this.
|
||||
- All routing logic can go into `/routes/api.js`
|
||||
- See the `puzzle-strings.js` file in `/controllers` for some sample puzzles your application should solve
|
||||
- To run the challenge tests on this page, set `NODE_ENV` to `test` without quotes in the `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Replit console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
|
||||
在 `tests/1_unit-tests.js` 中寫下以下測試:
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
|
||||
- 邏輯處理 81 個字符的解謎字符串
|
||||
- 邏輯處理無效的解謎字符串 (不是 1-9 或 `.`)
|
||||
- 邏輯處理一個長度不是 81 個字符的解謎字符串
|
||||
- 邏輯處理有效行的位置
|
||||
- 邏輯處理無效行的位置
|
||||
- 邏輯處理一個有效的列位置
|
||||
- 邏輯處理無效列位置
|
||||
- 邏輯處理一個有效的區域 (3x3 網格)
|
||||
- 邏輯處理一個無效的區域 (3x3 網格)
|
||||
- 有效解謎字符串通過 solver
|
||||
- 無效解謎字符串無法通過 solver
|
||||
- Solver 返回一個不完整謎題的的預期解決方案
|
||||
- Logic handles a valid puzzle string of 81 characters
|
||||
- Logic handles a puzzle string with invalid characters (not 1-9 or `.`)
|
||||
- Logic handles a puzzle string that is not 81 characters in length
|
||||
- Logic handles a valid row placement
|
||||
- Logic handles an invalid row placement
|
||||
- Logic handles a valid column placement
|
||||
- Logic handles an invalid column placement
|
||||
- Logic handles a valid region (3x3 grid) placement
|
||||
- Logic handles an invalid region (3x3 grid) placement
|
||||
- Valid puzzle strings pass the solver
|
||||
- Invalid puzzle strings fail the solver
|
||||
- Solver returns the expected solution for an incomplete puzzle
|
||||
|
||||
在 `tests/2_functional-tests.js` 中編寫下以下測試:
|
||||
Write the following tests in `tests/2_functional-tests.js`
|
||||
|
||||
- 用有效的解謎字符串解決一個謎題:POST 請求到 `/api/solve`
|
||||
- 用缺失的解謎字符串解決一個謎題:POST 請求到 `/api/solve`
|
||||
- 用無效字符解決一個謎題:POST 請求到 `/api/solve`
|
||||
- 用不正確的長度解決一個謎題:POST 請求到 `/api/solve`
|
||||
- 解決一個無法解決的謎題:POST 請求到 `/api/solve`
|
||||
- 檢查所有字段的解謎位置:POST 請求到 `/api/check`
|
||||
- 用單個位置衝突檢查解謎位置:POST 請求到 `/api/check`
|
||||
- 檢查一個有多個位置衝突的解謎位置: POST 請求到 `/api/check`
|
||||
- 檢查與所有位置衝突的解謎位置: POST 請求到 `/api/check`
|
||||
- 檢查缺失所需字段的解謎位置:POST 請求到 `/api/check`
|
||||
- 檢查一個有無效字符的解謎位置: POST 請求到 `/api/check`
|
||||
- 檢查不正確長度的解謎位置:POST 請求到 `/api/check`
|
||||
- 檢查一個無效的放置座標的解謎位置:POST 請求到 `/api/check`
|
||||
- 檢查具有無效的放置值的解謎位置:POST 請求到 `/api/check`
|
||||
- Solve a puzzle with valid puzzle string: POST request to `/api/solve`
|
||||
- Solve a puzzle with missing puzzle string: POST request to `/api/solve`
|
||||
- Solve a puzzle with invalid characters: POST request to `/api/solve`
|
||||
- Solve a puzzle with incorrect length: POST request to `/api/solve`
|
||||
- Solve a puzzle that cannot be solved: POST request to `/api/solve`
|
||||
- Check a puzzle placement with all fields: POST request to `/api/check`
|
||||
- Check a puzzle placement with single placement conflict: POST request to `/api/check`
|
||||
- Check a puzzle placement with multiple placement conflicts: POST request to `/api/check`
|
||||
- Check a puzzle placement with all placement conflicts: POST request to `/api/check`
|
||||
- Check a puzzle placement with missing required fields: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid characters: POST request to `/api/check`
|
||||
- Check a puzzle placement with incorrect length: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid placement coordinate: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid placement value: POST request to `/api/check`
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -70,7 +76,7 @@ dashedName: sudoku-solver
|
||||
};
|
||||
```
|
||||
|
||||
可以發送 `POST` 請求到 `/api/solve`,使用包含 `puzzle` 的表單數據這將是一個包含數字 (1-9) 和點號的字符串組合,`.` 表示空格。 返回的對象將包含一個 `solution` 屬性與解決的謎題。
|
||||
You can `POST` `/api/solve` with form data containing `puzzle` which will be a string containing a combination of numbers (1-9) and periods `.` to represent empty spaces. The returned object will contain a `solution` property with the solved puzzle.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -89,7 +95,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/solve` 的對象缺失 `puzzle`,返回的值將是 `{ error: 'Required field missing' }`
|
||||
If the object submitted to `/api/solve` is missing `puzzle`, the returned value will be `{ error: 'Required field missing' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -107,7 +113,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/solve` 謎題包含非數字或點號的值。 返回的值將是 `{ error: 'Invalid characters in puzzle' }`
|
||||
If the puzzle submitted to `/api/solve` contains values which are not numbers or periods, the returned value will be `{ error: 'Invalid characters in puzzle' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -125,7 +131,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/solve` 的謎題大於或小於 81 個字符, 返回的值將是 `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
If the puzzle submitted to `/api/solve` is greater or less than 81 characters, the returned value will be `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -147,7 +153,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/solve` 的謎題無效或無法解決, 返回的值將是 `{ error: 'Puzzle cannot be solved' }`
|
||||
If the puzzle submitted to `/api/solve` is invalid or cannot be solved, the returned value will be `{ error: 'Puzzle cannot be solved' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -165,7 +171,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以發送 `POST` 請求到 `/api/check`,包含 `puzzle`、`coordinate` 和 `value` 的對象,其中 `coordinate` 是表示行的字母 A-I,後跟表示列的數字 1-9,而 `value` 是 1-9 的數字。
|
||||
You can `POST` to `/api/check` an object containing `puzzle`, `coordinate`, and `value` where the `coordinate` is the letter A-I indicating the row, followed by a number 1-9 indicating the column, and `value` is a number from 1-9.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -184,7 +190,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
發送 `POST` 請求到 `/api/check`,返回值是一個包含 `valid` 屬性的對象,如果數字可能放置在提供的座標中則是 `true`,否則是`false`。 如果錯誤,返回的對象還將包含一個 `conflict` 屬性,它是一個字符串 `"row"`、`"column"`, 和/或 取決於哪個區域使位置無效的`"region"` 。
|
||||
The return value from the `POST` to `/api/check` will be an object containing a `valid` property, which is `true` if the number may be placed at the provided coordinate and `false` if the number may not. If false, the returned object will also contain a `conflict` property which is an array containing the strings `"row"`, `"column"`, and/or `"region"` depending on which makes the placement invalid.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -207,7 +213,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/check` 的 `value` 已放置在該 `coordinate` 上的 `puzzle`中,如果 `value` 不衝突,則返回的是 `valid` 屬性爲 `true` 的對象。
|
||||
If `value` submitted to `/api/check` is already placed in `puzzle` on that `coordinate`, the returned value will be an object containing a `valid` property with `true` if `value` is not conflicting.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -226,7 +232,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/check` 的謎題包含非數字或點號的值。 返回的值將是 `{ error: 'Invalid characters in puzzle' }`
|
||||
If the puzzle submitted to `/api/check` contains values which are not numbers or periods, the returned value will be `{ error: 'Invalid characters in puzzle' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -246,7 +252,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/check` 的謎題大於或小於 81 個字符, 返回的值將是 `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
If the puzzle submitted to `/api/check` is greater or less than 81 characters, the returned value will be `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -270,7 +276,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/check` 的對象缺失 `puzzle`、`coordinate` 或 `value`,那麼返回的值將是 `{ error: 'Required field(s) missing' }`。
|
||||
If the object submitted to `/api/check` is missing `puzzle`, `coordinate` or `value`, the returned value will be `{ error: 'Required field(s) missing' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -302,7 +308,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `api/check` 的座標不指向現有的網格單元格, 返回的值將是 `{ error: 'Invalid coordinate'}`
|
||||
If the coordinate submitted to `api/check` does not point to an existing grid cell, the returned value will be `{ error: 'Invalid coordinate'}`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -324,7 +330,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交給 `/api/check` 的 `value` 不是一個介於 1 到 9 之間的數字,則返回的值將是 `{ error: 'Invalid value' }`。
|
||||
If the `value` submitted to `/api/check` is not a number between 1 and 9, the returned value will be `{ error: 'Invalid value' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -346,7 +352,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 12 個單元的測試都已完成並通過。 請參閱 `/tests/1_unit-tests.js` 來了解你應該寫的測試的預期行爲。
|
||||
All 12 unit tests are complete and passing. See `/tests/1_unit-tests.js` for the expected behavior you should write tests for.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -371,7 +377,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 14 項功能測試都已完成並通過。 請參閱 `/tests/2_functional-tests.js` 來了解你應該編寫的測試的功能。
|
||||
All 14 functional tests are complete and passing. See `/tests/2_functional-tests.js` for the expected functionality you should write tests for.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: arithmetic-formatter
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-arithmetic-formatter" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
小學生經常把算術題垂直排列,這樣更容易解決。 例如,“235 + 52” 變成:
|
||||
@@ -58,16 +63,16 @@ arithmetic_arranger(["32 + 8", "1 - 3801", "9999 + 9999", "523 - 49"], True)
|
||||
如果提供的問題格式正確,該函數將返回正確的轉換,否則,它將 **返回** 一個 **字符串** 來描述對用戶有意義的錯誤。
|
||||
|
||||
|
||||
- 會返回錯誤的情況:
|
||||
- 如果提供給函數的 **問題過多**。 限制爲 **五個**,更多的將返回: `Error: Too many problems.`
|
||||
- 函數可以接受的運算符是 **加法** 和 **減法** 。 乘法和除法將返回錯誤。 本要點中未提及的其他運算符將不需要進行測試。 返回的錯誤將是: `Error: Operator must be '+' or '-'.`
|
||||
- 每個數字(操作數)應該只包含數字。 否則,該函數將返回: `Error: Numbers must only contain digits.`
|
||||
- 每個操作數(也就是運算符兩側的數字)的寬度最多爲四位。 否則,返回的錯誤字符串將爲: `Error: Numbers cannot be more than four digits.`
|
||||
- 如果用戶提供了正確格式的問題,返回的轉換將遵循以下規則:
|
||||
- 操作符和兩個操作數中最長的一個之間應該有一個空格,操作符將與第二個操作數在同一行,兩個操作數的順序與提供的相同(第一個是上面的,第二個是下面的)。
|
||||
- 數字應該右對齊。
|
||||
- 每個問題之間應該有四個空格。
|
||||
- 每個問題的底部都應該有破折號。 破折號應該單獨沿着每個問題的整個長度延伸。 (上面的例子展示了這應該是什麼樣子。)
|
||||
- Situations that will return an error:
|
||||
- If there are **too many problems** supplied to the function. The limit is **five**, anything more will return: `Error: Too many problems.`
|
||||
- The appropriate operators the function will accept are **addition** and **subtraction**. Multiplication and division will return an error. Other operators not mentioned in this bullet point will not need to be tested. The error returned will be: `Error: Operator must be '+' or '-'.`
|
||||
- Each number (operand) should only contain digits. Otherwise, the function will return: `Error: Numbers must only contain digits.`
|
||||
- Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be: `Error: Numbers cannot be more than four digits.`
|
||||
- If the user supplied the correct format of problems, the conversion you return will follow these rules:
|
||||
- There should be a single space between the operator and the longest of the two operands, the operator will be on the same line as the second operand, both operands will be in the same order as provided (the first will be the top one and the second will be the bottom).
|
||||
- Numbers should be right-aligned.
|
||||
- There should be four spaces between each problem.
|
||||
- There should be dashes at the bottom of each problem. The dashes should run along the entire length of each problem individually. (The example above shows what this should look like.)
|
||||
|
||||
## 開發
|
||||
|
||||
|
||||
@@ -10,21 +10,26 @@ dashedName: budget-app
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-budget-app" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
完成 `budget.py` 中的 `Category` 類。 它應該能夠根據不同的預算類別實例化對象,例如 *食物* 、 *服裝* 和 *娛樂* 。 創建對象時,它們以類別的名稱傳遞。 該類應該有一個名爲 `ledger` 的實例變量,它是一個列表。 該類還應包含以下方法:
|
||||
|
||||
- 接受金額和描述的 `deposit` 方法。 如果沒有給出描述,它應該默認爲一個空字符串。 該方法應以 `{"amount": amount, "description": description}` 的形式將對象附加到賬本列表。
|
||||
- `withdraw` 方法類似於 `deposit` 方法,但傳入的金額應作爲負數存儲在分類帳中。 如果沒有足夠的資金,則不應向分類帳添加任何內容。 如果取款發生,此方法應返回 `True`,否則返回 `False`。
|
||||
- `get_balance` 方法,根據發生的存款和取款返回預算類別的當前餘額。
|
||||
- 一個 `transfer` 方法,它接受一個金額和另一個預算類別作爲參數。 該方法應添加帶有金額和描述“Transfer to [目標預算類別]”的提款。 然後,該方法應將存款添加到其他預算類別,其金額和描述爲“Transfer from [來源預算類別]”。 如果沒有足夠的資金,則不應向任一分類帳添加任何內容。 如果轉賬發生,此方法應返回 `True`,否則返回 `False`。
|
||||
- 接受金額作爲參數的 `check_funds` 方法。 如果金額大於預算類別的餘額,則返回 `False`,否則返回 `True`。 `withdraw` 方法和 `transfer` 方法都應該使用此方法。
|
||||
- A `deposit` method that accepts an amount and description. If no description is given, it should default to an empty string. The method should append an object to the ledger list in the form of `{"amount": amount, "description": description}`.
|
||||
- A `withdraw` method that is similar to the `deposit` method, but the amount passed in should be stored in the ledger as a negative number. If there are not enough funds, nothing should be added to the ledger. This method should return `True` if the withdrawal took place, and `False` otherwise.
|
||||
- A `get_balance` method that returns the current balance of the budget category based on the deposits and withdrawals that have occurred.
|
||||
- A `transfer` method that accepts an amount and another budget category as arguments. The method should add a withdrawal with the amount and the description "Transfer to [Destination Budget Category]". The method should then add a deposit to the other budget category with the amount and the description "Transfer from [Source Budget Category]". If there are not enough funds, nothing should be added to either ledgers. This method should return `True` if the transfer took place, and `False` otherwise.
|
||||
- A `check_funds` method that accepts an amount as an argument. It returns `False` if the amount is greater than the balance of the budget category and returns `True` otherwise. This method should be used by both the `withdraw` method and `transfer` method.
|
||||
|
||||
打印預算對象時,它應顯示:
|
||||
|
||||
- 30 個字符的標題行,類別名稱居中在一行 `*` 字符中。
|
||||
- 分類帳中的項目列表。 每行應顯示描述和金額。 應顯示描述的前 23 個字符,然後是金額。 金額應右對齊,包含兩位小數,最多顯示 7 個字符。
|
||||
- 一行顯示類別總數。
|
||||
- A title line of 30 characters where the name of the category is centered in a line of `*` characters.
|
||||
- A list of the items in the ledger. Each line should show the description and amount. The first 23 characters of the description should be displayed, then the amount. The amount should be right aligned, contain two decimal places, and display a maximum of 7 characters.
|
||||
- A line displaying the category total.
|
||||
|
||||
下面是一個輸出示例:
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: polygon-area-calculator
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-polygon-area-calculator" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
在這個項目中,你將使用面向對象的編程來創建 Rectangle(矩形) 類和 Square(正方形) 類。 Square 類應該是 Rectangle 的子類,並繼承方法和屬性。
|
||||
@@ -20,11 +25,11 @@ dashedName: polygon-area-calculator
|
||||
|
||||
- `set_width`
|
||||
- `set_height`
|
||||
- `get_area`:返回面積(`width * height`)
|
||||
- `get_perimeter`:返回周長(`2 * width + 2 * height`)
|
||||
- `get_diagonal`:返回對角線 (`(width ** 2 + height ** 2) ** .5`)
|
||||
- `get_picture`:返回一個字符串,該字符串使用包含“\*”的行來表示形狀。 行數應等於高度,每行中“\*”的數量應等於寬度。 每行末尾應該有一個新行 (`\n`)。 如果寬度或高度大於 50,則應返回字符串:“Too big for picture.”。
|
||||
- `get_amount_inside`:以另一個形狀(正方形或矩形)作爲參數。 返回傳入的形狀可以裝進該形狀的次數(沒有旋轉)。 例如,一個寬爲 4,高爲 8 的矩形可以放入兩個邊長爲 4 的正方形。
|
||||
- `get_area`: Returns area (`width * height`)
|
||||
- `get_perimeter`: Returns perimeter (`2 * width + 2 * height`)
|
||||
- `get_diagonal`: Returns diagonal (`(width ** 2 + height ** 2) ** .5`)
|
||||
- `get_picture`: Returns a string that represents the shape using lines of "\*". The number of lines should be equal to the height and the number of "\*" in each line should be equal to the width. There should be a new line (`\n`) at the end of each line. If the width or height is larger than 50, this should return the string: "Too big for picture.".
|
||||
- `get_amount_inside`: Takes another shape (square or rectangle) as an argument. Returns the number of times the passed in shape could fit inside the shape (with no rotations). For instance, a rectangle with a width of 4 and a height of 8 could fit in two squares with sides of 4.
|
||||
|
||||
另外,如果一個 Rectangle 實例被表示爲一個字符串,它應該看起來像: `Rectangle(width=5, height=10)`
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: probability-calculator
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-probability-calculator" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
假設有一頂帽子,裏面有 5 個藍球、4 個紅球和 2 個綠球。 隨機抽取的 4 個球中至少包含 1 個紅球和 2 個綠球的概率是多少? 雖然可以使用高等數學來計算概率,但更簡單的方法是編寫一個程序來執行大量實驗來估計近似概率。
|
||||
@@ -30,10 +35,10 @@ hat3 = Hat(red=5, orange=4, black=1, blue=0, pink=2, striped=9)
|
||||
|
||||
接下來,在 `prob_calculator.py`(不是在 `Hat` 類中)創建一個 `experiment` 函數。 此函數應接受以下參數:
|
||||
|
||||
- `hat`:一個包含球的帽子對象,應該在函數內複製。
|
||||
- `expected_balls`:一個對象,指示嘗試從帽子中抽取的確切球組以進行實驗。 例如,要確定從帽子中抽取 2 個藍球和 1 個紅球的概率,將 `expected_balls` 設置爲 `{"blue":2, "red":1}`。
|
||||
- `num_balls_drawn`:每次實驗中從帽子中抽出的球數。
|
||||
- `num_experiments`:要執行的實驗數量。 (進行的實驗越多,近似概率就越準確。)
|
||||
- `hat`: A hat object containing balls that should be copied inside the function.
|
||||
- `expected_balls`: An object indicating the exact group of balls to attempt to draw from the hat for the experiment. For example, to determine the probability of drawing 2 blue balls and 1 red ball from the hat, set `expected_balls` to `{"blue":2, "red":1}`.
|
||||
- `num_balls_drawn`: The number of balls to draw out of the hat in each experiment.
|
||||
- `num_experiments`: The number of experiments to perform. (The more experiments performed, the more accurate the approximate probability will be.)
|
||||
|
||||
`experiment` 函數應該返回一個概率。
|
||||
|
||||
|
||||
@@ -10,13 +10,17 @@ dashedName: time-calculator
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-time-calculator" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
# --instructions--
|
||||
|
||||
編寫一個名爲 `add_time` 的函數,它接受兩個必需參數和一個可選參數:
|
||||
|
||||
- 12 小時制的開始時間(以 AM 或 PM 結束)
|
||||
- 指示小時數和分鐘數的持續時間
|
||||
- (可選)一週的開始日期,不區分大小寫
|
||||
- a start time in the 12-hour clock format (ending in AM or PM)
|
||||
- a duration time that indicates the number of hours and minutes
|
||||
- (optional) a starting day of the week, case insensitive
|
||||
|
||||
該函數應將持續時間添加到開始時間並返回結果。
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: demographic-data-analyzer
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-demographic-data-analyzer" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我們仍在開發 Python 課程的交互式教學部分。 目前,你可以在 YouTube 上通過 freeCodeCamp.org 上傳的一些視頻學習這個項目相關的知識。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">給所有人的 Python 課程</a>(14 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a> (14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析數據</a>(10 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -32,15 +37,15 @@ dashedName: demographic-data-analyzer
|
||||
|
||||
你必須使用 Pandas 來回答以下問題:
|
||||
|
||||
- 這個數據集中每個種族有多少人? 這應該是一個以種族名稱作爲索引標籤的 Pandas 系列。 (`race` 欄)
|
||||
- 男性的平均年齡是多少?
|
||||
- 擁有學士學位的人的百分比是多少?
|
||||
- 受過高等教育(`Bachelors`, `Masters`, or `Doctorate`)收入超過 50K 的人佔多大比例?
|
||||
- 沒有受過高等教育的人的收入超過 50K 的比例是多少?
|
||||
- 一個人每週最少工作多少小時?
|
||||
- 每週工作最少小時數的人中有多少人的工資超過 50K?
|
||||
- 哪個國家/地區的收入 >50K 的人口比例最高,該比例是多少?
|
||||
- 確定印度收入 >50K 的人最受歡迎的職業。
|
||||
- How many people of each race are represented in this dataset? This should be a Pandas series with race names as the index labels. (`race` column)
|
||||
- What is the average age of men?
|
||||
- What is the percentage of people who have a Bachelor's degree?
|
||||
- What percentage of people with advanced education (`Bachelors`, `Masters`, or `Doctorate`) make more than 50K?
|
||||
- What percentage of people without advanced education make more than 50K?
|
||||
- What is the minimum number of hours a person works per week?
|
||||
- What percentage of the people who work the minimum number of hours per week have a salary of more than 50K?
|
||||
- What country has the highest percentage of people that earn >50K and what is that percentage?
|
||||
- Identify the most popular occupation for those who earn >50K in India.
|
||||
|
||||
使用文件 `demographic_data_analyzer` 中的啓動代碼。 更新代碼,以便將所有設置爲“None”的變量設置爲適當的計算或代碼。 將所有小數四捨五入到最接近的十分之一。
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: mean-variance-standard-deviation-calculator
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-mean-variance-standard-deviation-calculator" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我們仍在開發 Python 課程的交互式教學部分。 目前,你可以在 YouTube 上通過 freeCodeCamp.org 上傳的一些視頻學習這個項目相關的知識。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">給所有人的 Python 課程</a>(14 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析數據</a>(10 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: medical-data-visualizer
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-medical-data-visualizer" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我們仍在開發 Python 課程的交互式教學部分。 目前,你可以在 YouTube 上通過 freeCodeCamp.org 上傳的一些視頻學習這個項目相關的知識。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">給所有人的 Python 課程</a>(14 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析數據</a>(10 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -47,16 +52,16 @@ dashedName: medical-data-visualizer
|
||||
|
||||
在 `medical_data_visualizer.py` 中使用數據完成以下任務:
|
||||
|
||||
- 給數據添加一列 `overweight`。 要確定一個人是否超重,首先通過將他們的體重(公斤)除以他們的身高(米)的平方來計算他們的 BMI。 如果該值 > 25,則此人超重。 使用值 0 表示不超重,使用值 1 表示超重。
|
||||
- 使用 0 表示好的和 1 表示壞,來規範化數據。 如果 `cholesterol` 或 `gluc` 的值爲 1,則將值設爲 0。 如果值大於 1,則將值設爲 1。
|
||||
- 將數據轉換爲長格式並使用 seaborn 的 `catplot()` 創建一個顯示分類特徵值計數的圖表。 數據集應按“Cardio”拆分,因此每個 `cardio` 值都有一個圖表。 該圖表應該看起來像 `examples/Figure_1.png`。
|
||||
- 清理數據。 過濾掉以下代表不正確數據的患者段:
|
||||
- 舒張壓高於收縮壓(使用 `(df['ap_lo'] <= df['ap_hi'])` 保留正確的數據)
|
||||
- 高度小於第 2.5 個百分位數(使用 `(df['height'] >= df['height'].quantile(0.025))` 保留正確的數據)
|
||||
- 身高超過第 97.5 個百分位
|
||||
- 體重小於第 2.5 個百分位
|
||||
- 體重超過第 97.5 個百分位
|
||||
- 使用數據集創建相關矩陣。 使用 seaborn 的 `heatmap()` 繪製相關矩陣。 遮罩上三角。 該圖表應類似於 `examples/Figure_2.png`。
|
||||
- Add an `overweight` column to the data. To determine if a person is overweight, first calculate their BMI by dividing their weight in kilograms by the square of their height in meters. If that value is > 25 then the person is overweight. Use the value 0 for NOT overweight and the value 1 for overweight.
|
||||
- Normalize the data by making 0 always good and 1 always bad. If the value of `cholesterol` or `gluc` is 1, make the value 0. If the value is more than 1, make the value 1.
|
||||
- Convert the data into long format and create a chart that shows the value counts of the categorical features using seaborn's `catplot()`. The dataset should be split by 'Cardio' so there is one chart for each `cardio` value. The chart should look like `examples/Figure_1.png`.
|
||||
- Clean the data. Filter out the following patient segments that represent incorrect data:
|
||||
- diastolic pressure is higher than systolic (Keep the correct data with `(df['ap_lo'] <= df['ap_hi'])`)
|
||||
- height is less than the 2.5th percentile (Keep the correct data with `(df['height'] >= df['height'].quantile(0.025))`)
|
||||
- height is more than the 97.5th percentile
|
||||
- weight is less than the 2.5th percentile
|
||||
- weight is more than the 97.5th percentile
|
||||
- Create a correlation matrix using the dataset. Plot the correlation matrix using seaborn's `heatmap()`. Mask the upper triangle. The chart should look like `examples/Figure_2.png`.
|
||||
|
||||
每當變量設置爲 `None` 時,請確保將其設置爲正確的代碼。
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: page-view-time-series-visualizer
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-page-view-time-series-visualizer" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我們仍在開發 Python 課程的交互式教學部分。 目前,你可以在 freeCodeCamp.org 的 YouTube 頻道中通過視頻學習到這個項目相關的所有知識
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">給所有人的 Python 課程</a>(14 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析數據</a>(10 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -22,11 +27,11 @@ dashedName: page-view-time-series-visualizer
|
||||
|
||||
使用數據完成以下任務:
|
||||
|
||||
- 使用 Pandas 從 “fcc-forum-pageviews.csv” 導入數據。 將索引設置爲 `date` 列。
|
||||
- 通過過濾掉頁面瀏覽量位於數據集前 2.5% 或數據集後 2.5% 的日期來清理數據。
|
||||
- 創建一個 `draw_line_plot` 函數,該函數使用 Matplotlib 繪製類似於“examples/Figure_1.png”的折線圖。 標題應爲 `Daily freeCodeCamp Forum Page Views 5/2016-12/2019`。 x 軸上的標籤應爲 `Date`,y 軸上的標籤應爲 `Page Views`。
|
||||
- 創建一個 `draw_bar_plot` 函數,用於繪製類似於“examples/Figure_2.png”的條形圖。 它應該顯示按年份分組的每個月的平均每日頁面瀏覽量。 圖例應顯示月份標籤並具有 `Months` 標題。 在圖表上,x 軸上的標籤應爲 `Years`,y 軸上的標籤應爲 `Average Page Views`。
|
||||
- 創建一個 `draw_box_plot` 函數,該函數使用 Seaborn 繪製兩個相鄰的箱形圖,類似於“examples/Figure_3.png”。 這些箱線圖應顯示值在給定年份或月份內的分佈情況以及隨時間推移的比較情況。 第一個圖表的標題應爲 `Year-wise Box Plot (Trend)`,第二個圖表的標題應爲 `Month-wise Box Plot (Seasonality)`。 確保底部的月份標籤從 `Jan` 開始,並且 x 和 y 軸標記正確。 樣板文件包括準備數據的命令。
|
||||
- Use Pandas to import the data from "fcc-forum-pageviews.csv". Set the index to the `date` column.
|
||||
- Clean the data by filtering out days when the page views were in the top 2.5% of the dataset or bottom 2.5% of the dataset.
|
||||
- Create a `draw_line_plot` function that uses Matplotlib to draw a line chart similar to "examples/Figure_1.png". The title should be `Daily freeCodeCamp Forum Page Views 5/2016-12/2019`. The label on the x axis should be `Date` and the label on the y axis should be `Page Views`.
|
||||
- Create a `draw_bar_plot` function that draws a bar chart similar to "examples/Figure_2.png". It should show average daily page views for each month grouped by year. The legend should show month labels and have a title of `Months`. On the chart, the label on the x axis should be `Years` and the label on the y axis should be `Average Page Views`.
|
||||
- Create a `draw_box_plot` function that uses Seaborn to draw two adjacent box plots similar to "examples/Figure_3.png". These box plots should show how the values are distributed within a given year or month and how it compares over time. The title of the first chart should be `Year-wise Box Plot (Trend)` and the title of the second chart should be `Month-wise Box Plot (Seasonality)`. Make sure the month labels on bottom start at `Jan` and the x and y axis are labeled correctly. The boilerplate includes commands to prepare the data.
|
||||
|
||||
對於每個圖表,請確保使用數據框的副本。 單元測試是在 `test_module.py` 下爲你編寫的。
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: sea-level-predictor
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-sea-level-predictor" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我們仍在開發 Python 課程的交互式教學部分。 目前,你可以在 YouTube 上通過 freeCodeCamp.org 上傳的一些視頻學習這個項目相關的知識。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">給所有人的 Python 課程</a>(14 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析數據</a>(10 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -22,11 +27,11 @@ dashedName: sea-level-predictor
|
||||
|
||||
使用數據完成以下任務:
|
||||
|
||||
- 使用 Pandas 從 `epa-sea-level.csv` 導入數據。
|
||||
- 使用 matplotlib 創建散點圖,使用 `Year` 列作爲 x 軸,將 `CSIRO Adjusted Sea Level` 列作爲 y 軸。
|
||||
- 使用 `scipy.stats` 中的 `linregress` 函數來獲得最佳擬合線的斜率和 y 截距。 在散點圖的頂部繪製最佳擬合線。 使線穿過 2050 年以預測 2050 年的海平面上升。
|
||||
- 僅使用數據集中從 2000 年到最近一年的數據繪製一條新的最佳擬合線。 如果上升速度繼續與 2000 年一樣,則使該線也經過 2050 年以預測 2050 年的海平面上升。
|
||||
- x 標籤應爲 `Year`,y 標籤應爲 `Sea Level (inches)`,標題應爲 `Rise in Sea Level`。
|
||||
- Use Pandas to import the data from `epa-sea-level.csv`.
|
||||
- Use matplotlib to create a scatter plot using the `Year` column as the x-axis and the `CSIRO Adjusted Sea Level` column as the y-axix.
|
||||
- Use the `linregress` function from `scipy.stats` to get the slope and y-intercept of the line of best fit. Plot the line of best fit over the top of the scatter plot. Make the line go through the year 2050 to predict the sea level rise in 2050.
|
||||
- Plot a new line of best fit just using the data from year 2000 through the most recent year in the dataset. Make the line also go through the year 2050 to predict the sea level rise in 2050 if the rate of rise continues as it has since the year 2000.
|
||||
- The x label should be `Year`, the y label should be `Sea Level (inches)`, and the title should be `Rise in Sea Level`.
|
||||
|
||||
單元測試是在 `test_module.py` 下爲你編寫的。
|
||||
|
||||
|
||||
@@ -16,7 +16,13 @@ dashedName: anonymous-message-board
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-messageboard" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用一個你喜歡的站點生成器來完成項目。 需要確定包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後將 URL 提交到 `Solution Link` 中。 此外,還可以提交一個指向項目源碼的 `GitHub Link`。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -24,22 +30,22 @@ dashedName: anonymous-message-board
|
||||
2. 建議在 `routes/api.js` 中創建控制器/處理器並處理路由。
|
||||
3. 你將在 `server.js` 中添加任何安全功能。
|
||||
|
||||
在 `tests/2_functional-tests.js` 中編寫下以下測試:
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
|
||||
- 創建一個新的主題:發送 POST 請求到 `/api/threads/{board}`。
|
||||
- 查看最近的 10 個主題,每個主題有 3 個回覆:發送 GET 請求到 `/api/threads/{board}`
|
||||
- 使用錯誤密碼刪除主題:使用錯誤的`delete_password`向`/api/threads/{board}`發出DELETE請求
|
||||
- 用正確的密碼刪除一個主題:向`/api/threads/{board}`發出DELETE請求,並提供有效的`delete_password`。
|
||||
- 報告一個主題:發送 PUT 請求到 `/api/threads/{board}`。
|
||||
- 創建一個新的回覆:發送 POST 請求到 `/api/replies/{board}`。
|
||||
- 查看一個帶有所有回覆的主題:發送 GET 請求到`/api/replies/{board}`。
|
||||
- 使用錯誤密碼刪除一個回覆:使用無效的`delete_password`向`/api/replies/{board}`發出DELETE請求。
|
||||
- 使用正確密碼刪除一個回覆:使用有效的`delete_password`向`/api/replies/{board}`發出DELETE請求。
|
||||
- 報告一個回覆:發送 PUT 請求到 `/api/replies/{board}`。
|
||||
- Creating a new thread: POST request to `/api/threads/{board}`
|
||||
- Viewing the 10 most recent threads with 3 replies each: GET request to `/api/threads/{board}`
|
||||
- Deleting a thread with the incorrect password: DELETE request to `/api/threads/{board}` with an invalid `delete_password`
|
||||
- Deleting a thread with the correct password: DELETE request to `/api/threads/{board}` with a valid `delete_password`
|
||||
- Reporting a thread: PUT request to `/api/threads/{board}`
|
||||
- Creating a new reply: POST request to `/api/replies/{board}`
|
||||
- Viewing a single thread with all replies: GET request to `/api/replies/{board}`
|
||||
- Deleting a reply with the incorrect password: DELETE request to `/api/replies/{board}` with an invalid `delete_password`
|
||||
- Deleting a reply with the correct password: DELETE request to `/api/replies/{board}` with a valid `delete_password`
|
||||
- Reporting a reply: PUT request to `/api/replies/{board}`
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的項目,而不是示例的 URL。
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -51,7 +57,7 @@ dashedName: anonymous-message-board
|
||||
};
|
||||
```
|
||||
|
||||
只允許你的網站在你自己的頁面上以 iFrame 方式加載。
|
||||
Only allow your site to be loaded in an iFrame on your own pages.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -61,7 +67,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
不允許 DNS 預取。
|
||||
Do not allow DNS prefetching.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -71,7 +77,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
只允許你的網站爲你自己的頁面發送 referrer 請求頭。
|
||||
Only allow your site to send the referrer for your own pages.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -81,7 +87,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/threads/{board}` 發送一個 POST 請求,其中包括 `text` 和 `delete_password` 的表單數據。 保存的數據庫記錄將至少有 `_id`、`text`、`created_on`(date & time)、`bumped_on`(date & time, starts same as `created_on`)、`reported`(布爾值)、`delete_password`、& `replies`(數組)。
|
||||
You can send a POST request to `/api/threads/{board}` with form data including `text` and `delete_password`. The saved database record will have at least the fields `_id`, `text`, `created_on`(date & time), `bumped_on`(date & time, starts same as `created_on`), `reported` (boolean), `delete_password`, & `replies` (array).
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -113,7 +119,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/replies/{board}` 發送一個 POST 請求,其中包括字段 `text`、`delete_password` & `thread_id`。 這將更新 `bumped_on` 日期到評論日期。 在主題的 `replies` 數組中,將保存一個對象,至少有 `_id`、`text`、`created_on`、`delete_password`、& `reported` 這些屬性。
|
||||
You can send a POST request to `/api/replies/{board}` with form data including `text`, `delete_password`, & `thread_id`. This will update the `bumped_on` date to the comment's date. In the thread's `replies` array, an object will be saved with at least the properties `_id`, `text`, `created_on`, `delete_password`, & `reported`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -150,7 +156,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/threads/{board}` 發送一個 GET 請求。 返回的將是一個數組,包括論壇上最近的 10 個被回覆的主題,及每個主題最新的 3 個回帖。 `reported` 和 `delete_password` 字段將不會被髮送到客戶端。
|
||||
You can send a GET request to `/api/threads/{board}`. Returned will be an array of the most recent 10 bumped threads on the board with only the most recent 3 replies for each. The `reported` and `delete_password` fields will not be sent to the client.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -181,7 +187,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/replies/{board}?thread_id={thread_id}` 發送一個 GET 請求。 返回的將是帶有所有的回覆的整個主題,不包括與之前測試相同的客戶端字段。
|
||||
You can send a GET request to `/api/replies/{board}?thread_id={thread_id}`. Returned will be the entire thread with all its replies, also excluding the same fields from the client as the previous test.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -213,7 +219,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/threads/{board}` 發送一個 DELETE 請求,並傳遞 `thread_id` & `delete_password` 來刪除該線程。 返回的將是字符串 `incorrect password` 或 `success`。
|
||||
You can send a DELETE request to `/api/threads/{board}` and pass along the `thread_id` & `delete_password` to delete the thread. 返回的將是字符串 `incorrect password` 或 `success`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -250,7 +256,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/replies/{board}` 發送一個 DELETE 請求,並傳遞 `thread_id`、`reply_id`、& `delete_password`。 返回的將是字符串 `incorrect password` 或 `success`。 成功後,`reply_id` 的文本將更改爲 `[deleted]`。
|
||||
You can send a DELETE request to `/api/replies/{board}` and pass along the `thread_id`, `reply_id`, & `delete_password`. Returned will be the string `incorrect password` or `success`. On success, the text of the `reply_id` will be changed to `[deleted]`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -305,7 +311,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/threads/{board}` 發送一個 PUT 請求,並傳遞 `thread_id`。 返回的將是字符串 `reported`。 `thread_id` 回覆的 `reported` 值將改爲 `true`。
|
||||
You can send a PUT request to `/api/threads/{board}` and pass along the `thread_id`. 返回的將是字符串 `reported`。 The `reported` value of the `thread_id` will be changed to `true`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -336,7 +342,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以通過向 `/api/replies/{board}` 發送 PUT 請求並傳遞 `thread_id` & `reply_id`。 返回的將是字符串 `reported`。 `reply_id` 的 `reported` 值將被改變爲 `true`。
|
||||
You can send a PUT request to `/api/replies/{board}` and pass along the `thread_id` & `reply_id`. Returned will be the string `reported`. The `reported` value of the `reply_id` will be changed to `true`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -368,7 +374,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 10 項功能測試都已完成並通過。
|
||||
All 10 functional tests are complete and passing.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -11,13 +11,18 @@ dashedName: port-scanner
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-port-scanner" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我們仍在開發 Python 課程的交互式教學部分。 目前,你可以在 YouTube 上通過 freeCodeCamp.org 上傳的一些視頻學習這個項目相關的知識。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">給所有人的 Python 課程</a>(14 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a> (14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/" target="_blank" rel="noopener noreferrer nofollow">深入學習 Python 基礎知識</a>(4 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/" target="_blank" rel="noopener noreferrer nofollow">Learn Python Basics in Depth</a> (4 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/intermediate-python-course/" target="_blank" rel="noopener noreferrer nofollow">Python 中級課程</a>(6 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/intermediate-python-course/" target="_blank" rel="noopener noreferrer nofollow">Intermediate Python Course</a> (6 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
||||
@@ -14,26 +14,32 @@ dashedName: secure-real-time-multiplayer-game
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-secure-real-time-multiplayer-game" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目
|
||||
- 使用您選擇的站點生成器來完成項目。 需要確定包含了我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 框中提交你的項目 URL。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
創建一個安全的多人遊戲,每名玩家可以移動他們的角色,並且這個遊戲至少提供了一個可收集的道具,玩家的排名是根據他們的分數計算的。
|
||||
Create a secure multiplayer game in which each player can move their avatar, there is at least one collectible item, and the rank of the players is calculated based on their score.
|
||||
|
||||
有關詳細信息,請參考下面的測試。
|
||||
For details consult the tests below.
|
||||
|
||||
請確保你的遊戲是安全的! 包含以下安全措施:
|
||||
Make sure that your game is secure! Include these security measures:
|
||||
|
||||
- 客戶端不能猜測/嗅探 MIME 類型
|
||||
- 防止 XSS 攻擊
|
||||
- 不要在客戶端中緩存網站的任何信息
|
||||
- 在請求頭中聲明網站是由 `PHP 7.4.3` 提供技術支持
|
||||
- The client should not be able to guess/sniff the MIME type
|
||||
- Prevent XSS attacks
|
||||
- Do not cache anything from the website in the client
|
||||
- The headers say that the site is powered by `PHP 7.4.3`
|
||||
|
||||
**注意:** `helmet@^3.21.3` 是需求中所要求的。 這意味着你將需要使用之前版本的 Helmet 文檔,來了解如何實現需求。
|
||||
**Note**: `helmet@^3.21.3` is needed for the user stories. This means you will need to use the previous version of Helmet's docs, for information on how to achieve the user stories.
|
||||
|
||||
# --hints--
|
||||
|
||||
你應該提交你自己的項目,而不是示例 URL
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -45,91 +51,91 @@ dashedName: secure-real-time-multiplayer-game
|
||||
};
|
||||
```
|
||||
|
||||
多名玩家可以連接到同一臺服務器玩這個遊戲。
|
||||
Multiple players can connect to a server and play.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
每名玩家都有一個角色。
|
||||
Each player has an avatar.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
每名玩家都由 `Player.mjs` 中的 `Player` 類創建的對象表示
|
||||
Each player is represented by an object created by the `Player` class in `Player.mjs`.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
至少,每個玩家對象都應該包含一個唯一的 `id`、一個`score`,以及代表玩家當前位置的 `x` 和 `y` 座標。
|
||||
At a minimum, each player object should contain a unique `id`, a `score`, and `x` and `y` coordinates representing the player's current position.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
遊戲中至少有一種可收集道具。 在 `Collectible.mjs` 中完成 `Collectible` 類來實現這一點
|
||||
The game has at least one type of collectible item. Complete the `Collectible` class in `Collectible.mjs` to implement this.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
至少,由 `Collectible` 類創建的每個可收集物品對象應該包含一個唯一的 `id`、一個 `value` 和代表物品的當前位置 `x` 和 `y` 座標。
|
||||
At a minimum, each collectible item object created by the `Collectible` class should contain a unique `id`, a `value`, and `x` and `y` coordinates representing the item's current position.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
玩家可以使用 WASD 和/或箭頭鍵移動他們的角色。 完成 `Player.mjs` 中的 `movePlayer` 方法來實現這一功能。
|
||||
Players can use the WASD and/or arrow keys to move their avatar. Complete the `movePlayer` method in `Player.mjs` to implement this.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
`movePlayer` 方法應該接受兩個參數:一個由 “up”、“down”、“left” 或 “right” 組成的字符串,以及一個表示玩家位置應該改變的像素數量的數字。 `movePlayer` 應該調整被調用的玩家對象的 `x` 和 `y` 座標。
|
||||
The `movePlayer` method should accept two arguments: a string of "up", "down", "left", or "right", and a number for the amount of pixels the player's position should change. `movePlayer` should adjust the `x` and `y` coordinates of the player object it's called from.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
玩家的分數應該用來計算他們與其他玩家相比的排名。 完成 `Player` 類中的 `calculateRank` 方法來實現這個功能。
|
||||
The player's score should be used to calculate their rank among the other players. Complete the `calculateRank` method in the `Player` class to implement this.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
`calculateRank` 方法應該接受一個代表所有連接的玩家的對象數組,並返回字符串 `Rank: currentRanking/totalPlayers`(排名:當前排名/總玩家數)。 舉個例子,在一個兩人遊戲中,如果玩家 A 有 3 分,玩家 B 有 5 分,那麼玩家 A 的 `calculateRank` 應該返回 `Rank: 2/2`。
|
||||
The `calculateRank` method should accept an array of objects representing all connected players and return the string `Rank: currentRanking/totalPlayers`. For example, in a game with two players, if Player A has a score of 3 and Player B has a score of 5, `calculateRank` for Player A should return `Rank: 2/2`.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
玩家可以與收集道具發生碰撞。 完成 `Player.mjs` 中的 `collision` 方法實現這一功能。
|
||||
Players can collide with a collectible item. Complete the `collision` method in `Player.mjs` to implement this.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
`collision` 方法應該接受可收集物品的對象作爲參數。 如果玩家的角色與道具重合,`collision` 方法應該返回 `true`。
|
||||
The `collision` method should accept a collectible item's object as an argument. If the player's avatar intersects with the item, the `collision` method should return `true`.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
所有玩家保持同步。
|
||||
All players are kept in sync.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
玩家可以在任何時候退出遊戲。
|
||||
Players can disconnect from the game at any time.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
防止客戶端嘗試猜測/嗅探 MIME 類型。
|
||||
Prevent the client from trying to guess / sniff the MIME type.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -139,7 +145,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
防止跨站腳本(XSS)攻擊。
|
||||
Prevent cross-site scripting (XSS) attacks.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -149,7 +155,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
網站上的任何東西都不會被緩存到客戶端中。
|
||||
Nothing from the website is cached in the client.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -165,7 +171,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
在請求頭中聲明該網站由 “PHP 7.4.3” 提供技術支持,儘管它並非如此(作爲一種安全措施)。
|
||||
The headers say that the site is powered by "PHP 7.4.3" even though it isn't (as a security measure).
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -11,13 +11,18 @@ dashedName: sha-1-password-cracker
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-SHA-1-password-cracker" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我們仍在開發 Python 課程的交互式教學部分。 目前,你可以在 YouTube 上通過 freeCodeCamp.org 上傳的一些視頻學習這個項目相關的知識。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">給所有人的 Python 課程</a>(14 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a> (14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/" target="_blank" rel="noopener noreferrer nofollow">深入學習 Python 基礎知識</a>(4 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/" target="_blank" rel="noopener noreferrer nofollow">Learn Python Basics in Depth</a> (4 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/intermediate-python-course/" target="_blank" rel="noopener noreferrer nofollow">Python 中級課程</a>(6 小時)
|
||||
- <a href="https://www.freecodecamp.org/news/intermediate-python-course/" target="_blank" rel="noopener noreferrer nofollow">Intermediate Python Course</a> (6 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -33,15 +38,15 @@ dashedName: sha-1-password-cracker
|
||||
|
||||
以下是一些用於測試該功能的散列密碼:
|
||||
|
||||
- `b305921a3723cd5d70a375cd21a61e60aabb84ec` 應該返回 “sammy123”
|
||||
- `c7ab388a5ebefbf4d550652f1eb4d833e5316e3e` 應該返回 “abacab”
|
||||
- `5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8` 應該返回 “password”
|
||||
- `b305921a3723cd5d70a375cd21a61e60aabb84ec` should return "sammy123"
|
||||
- `c7ab388a5ebefbf4d550652f1eb4d833e5316e3e` should return "abacab"
|
||||
- `5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8` should return "password"
|
||||
|
||||
以下是一些散列密碼,用於在 `use_salts` 設置爲 `True` 時測試該功能:
|
||||
|
||||
- `53d8b3dc9d39f0184144674e310185e41a87ffd5` 應該返回 “superman”
|
||||
- `da5a4e8cf89539e66097acd2f8af128acae2f8ae` 應該返回 “q1w2e3r4t5”
|
||||
- `ea3f62d498e3b98557f9f9cd0d905028b3b019e1` 應該返回 “bubbles1”
|
||||
- `53d8b3dc9d39f0184144674e310185e41a87ffd5` should return "superman"
|
||||
- `da5a4e8cf89539e66097acd2f8af128acae2f8ae` should return "q1w2e3r4t5"
|
||||
- `ea3f62d498e3b98557f9f9cd0d905028b3b019e1` should return "bubbles1"
|
||||
|
||||
`hashlib` 庫已經爲你導入。 你應該在你的代碼中使用它。 <a href="https://docs.python.org/3/library/hashlib.html" target="_blank" rel="noopener noreferrer nofollow">在此瞭解更多關於 “hashlib” 的信息</a>。
|
||||
|
||||
|
||||
@@ -18,7 +18,13 @@ dashedName: stock-price-checker
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-stockchecker" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成你的項目。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後將 URL 提交到 `Solution Link` 中。 此外,還可以將項目的源碼提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -27,19 +33,19 @@ dashedName: stock-price-checker
|
||||
3. 添加安全功能到 `server.js`。
|
||||
4. 在 `tests/2_functional-tests.js` 中創建所有的功能測試
|
||||
|
||||
**注意** 隱私考慮:由於每個 IP 只能接受一個贊(like),你必須保存 IP 地址。 必須遵守數據隱私法規,例如《通用數據保護條例》。 一個選項是獲得保存用戶數據的權限,但是匿名化則要簡單得多。 對於此挑戰,請記住在將 IP 地址保存到數據庫之前對其進行匿名化。 如果你想知道如何做到這一點,你可以選擇散列數據、截斷它、或將 IP 地址的一部分設置爲 0。
|
||||
**Note** Privacy Considerations: Due to the requirement that only 1 like per IP should be accepted, you will have to save IP addresses. It is important to remain compliant with data privacy laws such as the General Data Protection Regulation. One option is to get permission to save the user's data, but it is much simpler to anonymize it. For this challenge, remember to anonymize IP addresses before saving them to the database. If you need ideas on how to do this, you may choose to hash the data, truncate it, or set part of the IP address to 0.
|
||||
|
||||
在 `tests/2_functional-tests.js` 中編寫以下測試:
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
|
||||
- 查看股價:發送 GET 請求到 `/api/stock-prices/`
|
||||
- 查看一個股票並關注它:發送 GET 請求到 `/api/stock-prices/`
|
||||
- 查看同一只股票並再次發送關注:發送 GET 請求到 `/api/stock-prices/`
|
||||
- 查看兩隻股票:發送 GET 請求到 `/api/stock-prices/`
|
||||
- 查看兩隻股票並關注它:發送 GET 請求到 `/api/stock-prices/`
|
||||
- Viewing one stock: GET request to `/api/stock-prices/`
|
||||
- Viewing one stock and liking it: GET request to `/api/stock-prices/`
|
||||
- Viewing the same stock and liking it again: GET request to `/api/stock-prices/`
|
||||
- Viewing two stocks: GET request to `/api/stock-prices/`
|
||||
- Viewing two stocks and liking them: GET request to `/api/stock-prices/`
|
||||
|
||||
# --hints--
|
||||
|
||||
提交你自己的項目,而不是示例的 URL。
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -49,7 +55,7 @@ dashedName: stock-price-checker
|
||||
};
|
||||
```
|
||||
|
||||
將內容安全策略設置爲僅允許從服務器加載腳本和 CSS。
|
||||
You should set the content security policies to only allow loading of scripts and CSS from your server.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -64,7 +70,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/stock-prices` 發送一個 `GET` 請求,將納斯達克股票代碼賦值給 `stock` 查詢參數。 返回的對象將包含一個名爲 `stockData` 的屬性。
|
||||
You can send a `GET` request to `/api/stock-prices`, passing a NASDAQ stock symbol to a `stock` query parameter. The returned object will contain a property named `stockData`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -76,7 +82,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`stockData` 屬性包括字符串 `stock`、數字 `price`,以及數字 `likes`。
|
||||
The `stockData` property includes the `stock` symbol as a string, the `price` as a number, and `likes` as a number.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -91,13 +97,13 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你也可以將 `like` 字段作爲 `true`(布爾值)傳遞,讓你的偏好添加到股票中。 每個 IP 應該只接受 1 個贊(like)。
|
||||
You can also pass along a `like` field as `true` (boolean) to have your like added to the stock(s). Only 1 like per IP should be accepted.
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
如果你傳遞了兩隻股票,返回值將是一個包含這兩隻股票信息的數組。 它將會顯示對於兩個 `stockData` 對象的 `rel_likes`(兩隻股票所獲得的贊同數的區別),而不是 `likes`。
|
||||
If you pass along 2 stocks, the returned value will be an array with information about both stocks. Instead of `likes`, it will display `rel_likes` (the difference between the likes on both stocks) for both `stockData` objects.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -112,7 +118,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 5 項功能測試都已完成並通過。
|
||||
All 5 functional tests are complete and passing.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,19 +14,25 @@ dashedName: install-and-require-helmet
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-infosec" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 上的初始化項目</a>來完成這些挑戰。
|
||||
- 使用你選擇的網站生成器來完成項目。 需要包含我們 GitHub 倉庫的所有文件。
|
||||
|
||||
完成本項目後,請將一個正常運行的 demo(項目演示)託管在可以公開訪問的平臺。 然後在 `Solution Link` 字段中提交它的 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
Helmet 通過設置各種 HTTP 頭來保護你的 Express 應用程序。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
Helmet helps you secure your Express apps by setting various HTTP headers.
|
||||
|
||||
# --instructions--
|
||||
|
||||
你在這些課程中寫的所有代碼都在 `myApp.js` 文件中,在初始代碼之間。 不要改變或刪除我們爲你添加的代碼。
|
||||
All your code for these lessons goes in the `myApp.js` file between the lines of code we have started you off with. Do not change or delete the code we have added for you.
|
||||
|
||||
Helmet `3.21.3` 版已經安裝完畢,所以在 `myApp.js` 中請求它作爲 `helmet`。
|
||||
Helmet version `3.21.3` has already been installed, so require it as `helmet` in `myApp.js`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`helmet` 版本 `3.21.3` 應該在 `package.json` 中。
|
||||
`helmet` version `3.21.3` should be in `package.json`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -12,6 +12,10 @@ dashedName: rock-paper-scissors
|
||||
|
||||
你將使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-rock-paper-scissors" target="_blank" rel="noopener noreferrer nofollow">我們在 Replit 的初始化項目</a>來完成這個項目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
我們仍在開發機器學習課程的交互式課程部分。 現在,你需要使用其他資源來學習如何通過這一挑戰。
|
||||
|
||||
# --instructions--
|
||||
@@ -32,9 +36,9 @@ dashedName: rock-paper-scissors
|
||||
|
||||
要測試你的代碼,請使用 `play` 函數玩遊戲。 `play` 函數有四個參數:
|
||||
|
||||
- 兩個玩家互相對戰(玩家實際上是函數)
|
||||
- 比賽的比賽場數
|
||||
- 一個可選參數來查看每場比賽的日誌。 將其設置爲 `True` 以查看這些消息。
|
||||
- two players to play against each other (the players are actually functions)
|
||||
- the number of games to play in the match
|
||||
- an optional argument to see a log of each game. Set it to `True` to see these messages.
|
||||
|
||||
```py
|
||||
play(player1, player2, num_games[, verbose])
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-43
|
||||
|
||||
# --description--
|
||||
|
||||
Increase the pseudo-element's transparency by `30%`.
|
||||
將僞元素的透明度提高 `30%`。
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@@ -14,13 +14,19 @@ dashedName: exercise-tracker
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-exercisetracker" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目。
|
||||
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
你的答案应该有以下结构。
|
||||
Your responses should have the following structures.
|
||||
|
||||
运动:
|
||||
Exercise:
|
||||
|
||||
```js
|
||||
{
|
||||
@@ -32,7 +38,7 @@ dashedName: exercise-tracker
|
||||
}
|
||||
```
|
||||
|
||||
用户:
|
||||
User:
|
||||
|
||||
```js
|
||||
{
|
||||
@@ -41,7 +47,7 @@ dashedName: exercise-tracker
|
||||
}
|
||||
```
|
||||
|
||||
日志:
|
||||
Log:
|
||||
|
||||
```js
|
||||
{
|
||||
@@ -56,11 +62,11 @@ dashedName: exercise-tracker
|
||||
}
|
||||
```
|
||||
|
||||
**提示:** 对于 `date` 属性,`Date` API 的 `toDateString` 方法可以用于实现预期的输出。
|
||||
**Hint:** For the `date` property, the `toDateString` method of the `Date` API can be used to achieve the expected output.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -71,7 +77,7 @@ dashedName: exercise-tracker
|
||||
};
|
||||
```
|
||||
|
||||
可以将表单里的 `username` 通过 `POST` 请求发送到 `/api/users`,以创建一个新的用户。
|
||||
You can `POST` to `/api/users` with form data `username` to create a new user.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -88,7 +94,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`POST /api/users` 带有表单数据 `username` 对请求,返回的响应将是一个具有 `username` 和 `_id` 属性的对象.
|
||||
The returned response from `POST /api/users` with form data `username` will be an object with `username` and `_id` properties.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -108,7 +114,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以向 `/api/users` 发出 `GET` 请求以获取所有用户的列表。
|
||||
You can make a `GET` request to `/api/users` to get a list of all users.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -121,7 +127,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
对 `/api/users` 的 `GET` 请求返回一个数组。
|
||||
The `GET` request to `/api/users` returns an array.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -136,7 +142,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
从 `GET /api/users` 返回的数组中的每个元素都是一个对象字面量,包含用户的 `username` 和 `_id`。
|
||||
Each element in the array returned from `GET /api/users` is an object literal containing a user's `username` and `_id`.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -156,7 +162,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你能用表单里的 `description`、`duration` 和 `date`(可选)发送 `POST` 请求到 `/api/users/:_id/exercises`。 如果没有传入 date,默认采用当前日期。
|
||||
You can `POST` to `/api/users/:_id/exercises` with form data `description`, `duration`, and optionally `date`. If no date is supplied, the current date will be used.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -190,7 +196,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
从 `POST /api/users/:_id/exercises` 返回的响应将是添加了运动字段的用户对象。
|
||||
The response returned from `POST /api/users/:_id/exercises` will be the user object with the exercise fields added.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -229,7 +235,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以发送 `GET` 请求到 `/api/users/:_id/logs`,以获取任何用户的完整 exercise 日志。
|
||||
You can make a `GET` request to `/api/users/:_id/logs` to retrieve a full exercise log of any user.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -268,7 +274,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
对用户日志的请求 `GET /api/users/:_id/logs` 返回一个用户对象,该对象具有一个 `count` 属性,表示属于该用户的运动次数。
|
||||
A request to a user's log `GET /api/users/:_id/logs` returns a user object with a `count` property representing the number of exercises that belong to that user.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -309,7 +315,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
对 `/api/users/:_id/logs` 的 `GET` 请求,将返回用户对象,其中包含添加的所有练习的 `log` 数组。
|
||||
A `GET` request to `/api/users/:_id/logs` will return the user object with a `log` array of all the exercises added.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -353,7 +359,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
从 `GET /api/users/:_id/logs` 返回的 `log` 数组中的每个项目都是一个应该具有 `description`、`duration` 和 `date` 属性的对象。
|
||||
Each item in the `log` array that is returned from `GET /api/users/:_id/logs` is an object that should have a `description`, `duration`, and `date` properties.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -400,7 +406,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
从 `GET /api/users/:_id/logs` 返回的 `log` 数组中任何对象的 `description` 属性都应该是一个字符串。
|
||||
The `description` property of any object in the `log` array that is returned from `GET /api/users/:_id/logs` should be a string.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -447,7 +453,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
从 `GET /api/users/:_id/logs` 返回的 `log` 数组中任何对象的 `duration` 属性应该是一个数字。
|
||||
The `duration` property of any object in the `log` array that is returned from `GET /api/users/:_id/logs` should be a number.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -494,7 +500,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
从 `GET /api/users/:_id/logs` 返回的 `log` 数组中任何对象的 `date` 属性应该是一个字符串。 使用 `Date` API 的 `dateString` 格式。
|
||||
The `date` property of any object in the `log` array that is returned from `GET /api/users/:_id/logs` should be a string. Use the `dateString` format of the `Date` API.
|
||||
|
||||
```js
|
||||
async(getUserInput) => {
|
||||
@@ -541,7 +547,7 @@ async(getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以将 `from`、`to` 和 `limit` 参数添加到 `GET /api/users/:_id/logs` 请求检索任何用户的部分日志。 `from` 和 `to` 是 `yyyy-mm-dd` 形式的日期, `limit` 是希望返回的 log 数量。
|
||||
You can add `from`, `to` and `limit` parameters to a `GET /api/users/:_id/logs` request to retrieve part of the log of any user. `from` and `to` are dates in `yyyy-mm-dd` format. `limit` is an integer of how many logs to send back.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,15 +14,21 @@ dashedName: file-metadata-microservice
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-filemetadata" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目。
|
||||
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
** 提示:** 可以使用 `multer` npm 包来处理上传文件
|
||||
**HINT:** You can use the `multer` npm package to handle file uploading.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -34,7 +40,7 @@ dashedName: file-metadata-microservice
|
||||
};
|
||||
```
|
||||
|
||||
可以提交一个包含上传文件的表单。
|
||||
You can submit a form that includes a file upload.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -45,7 +51,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
表单的文件上传标签的 `name` 属性设置成 `upfile`。
|
||||
The form file input field has the `name` attribute set to `upfile`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -56,7 +62,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
当提交一个文件时,在 JSON 响应中收到文件的 `name`、`type` 和`size`(以 bytes(字节)为单位)。
|
||||
When you submit a file, you receive the file `name`, `type`, and `size` in bytes within the JSON response.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,11 +14,17 @@ dashedName: request-header-parser-microservice
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-headerparser" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目。
|
||||
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -30,7 +36,7 @@ dashedName: request-header-parser-microservice
|
||||
};
|
||||
```
|
||||
|
||||
向 `/api/whoami` 发送请求,返回一个 JSON 对象,这个JSON 对象应该含有存放 IP 地址的 `ipaddress` 键中。
|
||||
A request to `/api/whoami` should return a JSON object with your IP address in the `ipaddress` key.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -42,7 +48,7 @@ dashedName: request-header-parser-microservice
|
||||
);
|
||||
```
|
||||
|
||||
向 `/api/whoami` 发送请求,返回一个 JSON 对象,这个 JSON 对象应该含有存放语言首选项的 `language` 键。
|
||||
A request to `/api/whoami` should return a JSON object with your preferred language in the `language` key.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -54,7 +60,7 @@ dashedName: request-header-parser-microservice
|
||||
);
|
||||
```
|
||||
|
||||
向 `/api/whoami` 发送请求,返回一个 JSON 对象,这个 JSON 对象应该含有存放(发送请求的)软件的 `software` 键。
|
||||
A request to `/api/whoami` should return a JSON object with your software in the `software` key.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,13 +14,19 @@ dashedName: timestamp-microservice
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-timestamp" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目。
|
||||
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
**注意:** 时区转换不是本项目的目的,因此假设所有发送的有效日期将使用 `new Date()` 解析为 GMT 日期。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
**Note:** Time zones conversion is not a purpose of this project, so assume all sent valid dates will be parsed with `new Date()` as GMT dates.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -30,7 +36,7 @@ dashedName: timestamp-microservice
|
||||
};
|
||||
```
|
||||
|
||||
一个对 `/api/:date?` 的有效日期的请求应该返回一个 JSON 对象,该对象的 `unix` 键是输入日期的 Unix 时间戳,单位是毫秒(数字类型)。
|
||||
A request to `/api/:date?` with a valid date should return a JSON object with a `unix` key that is a Unix timestamp of the input date in milliseconds (as type Number)
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +54,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
对具有有效日期的 `/api/:date?` 的请求应返回一个带有 `utc` 键的 JSON 对象,该键是输入日期的字符串,格式为:`Thu, 01 Jan 1970 00:00:00 GMT`
|
||||
A request to `/api/:date?` with a valid date should return a JSON object with a `utc` key that is a string of the input date in the format: `Thu, 01 Jan 1970 00:00:00 GMT`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -66,7 +72,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
对 `/api/1451001600000` 的请求应该返回 `{ unix: 1451001600000, utc: "Fri, 25 Dec 2015 00:00:00 GMT" }`
|
||||
A request to `/api/1451001600000` should return `{ unix: 1451001600000, utc: "Fri, 25 Dec 2015 00:00:00 GMT" }`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -83,7 +89,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
你的项目可以处理可以通过 `new Date(date_string)` 成功解析的日期
|
||||
Your project can handle dates that can be successfully parsed by `new Date(date_string)`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -100,7 +106,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
如果输入的日期字符串无效,api 将返回一个具有结构的对象 `{ error : "Invalid Date" }`
|
||||
If the input date string is invalid, the api returns an object having the structure `{ error : "Invalid Date" }`
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -114,7 +120,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
一个空的日期参数应该返回一个带有 `unix` 键的 JSON 对象中的当前时间
|
||||
An empty date parameter should return the current time in a JSON object with a `unix` key
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -129,7 +135,7 @@ dashedName: timestamp-microservice
|
||||
);
|
||||
```
|
||||
|
||||
空日期参数应返回带有 `utc` 键的 JSON 对象中的当前时间
|
||||
An empty date parameter should return the current time in a JSON object with a `utc` key
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,15 +14,21 @@ dashedName: url-shortener-microservice
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-urlshortener" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目。
|
||||
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
**提示:** 请使用 body parsing 中间件来处理 POST 请求, 也可以使用 `dns` 核心模块中的 `dns.lookup(host, cb)` 函数验证提交的 URL。
|
||||
**HINT:** Do not forget to use a body parsing middleware to handle the POST requests. Also, you can use the function `dns.lookup(host, cb)` from the `dns` core module to verify a submitted URL.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -34,7 +40,7 @@ dashedName: url-shortener-microservice
|
||||
};
|
||||
```
|
||||
|
||||
可以通过 POST 请求给 `/api/shorturl` 发送一个 URL,并返回一个带有 `original_url` 和 `short_url` 属性的 JSON 响应。 例如:`{ original_url : 'https://freeCodeCamp.org', short_url : 1}`。
|
||||
You can POST a URL to `/api/shorturl` and get a JSON response with `original_url` and `short_url` properties. Here's an example: `{ original_url : 'https://freeCodeCamp.org', short_url : 1}`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -56,7 +62,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
当访问 `/api/shorturl/<short_url>` 时, 将重定向到原来的 URL。
|
||||
When you visit `/api/shorturl/<short_url>`, you will be redirected to the original URL.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -88,7 +94,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果传入一个没有遵循如 `http://www.example.com` 的无效 URL,则返回包含 `{ error: 'invalid url' }` 的 JSON 响应。
|
||||
If you pass an invalid URL that doesn't follow the valid `http://www.example.com` format, the JSON response will contain `{ error: 'invalid url' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,21 +14,27 @@ dashedName: meet-the-node-console
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-express" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成这些挑战。
|
||||
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
在开发过程中,能够随时看到代码的运行结果是非常重要的。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
Node 只是一个 JavaScript 环境。 与客户端 JavaScript 一样,你可以使用控制台显示有用的调试信息。 在本地计算机上,你可以在终端中输出调试信息。 在 Replit 上,右侧边栏会默认打开一个终端。
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
我们建议在做这些挑战题时保持终端打开的状态。 通过这些终端的输出,你可能会发现这些错误的本质原因。
|
||||
During the development process, it is important to be able to check what’s going on in your code.
|
||||
|
||||
Node is just a JavaScript environment. Like client side JavaScript, you can use the console to display useful debug information. On your local machine, you would see console output in a terminal. On Replit, a terminal is open in the right pane by default.
|
||||
|
||||
We recommend to keep the terminal open while working at these challenges. By reading the output in the terminal, you can see any errors that may occur.
|
||||
|
||||
# --instructions--
|
||||
|
||||
修改 `myApp.js` 文件,在控制台打印出 “Hello World”。
|
||||
Modify the `myApp.js` file to log "Hello World" to the console.
|
||||
|
||||
# --hints--
|
||||
|
||||
控制台应该输出 `"Hello World"`
|
||||
`"Hello World"` should be in the console
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,13 +14,19 @@ dashedName: how-to-use-package-json-the-core-of-any-node-js-project-or-npm-packa
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-npm" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成这些挑战。
|
||||
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
`package.json` 文件是所有 Node.js 项目和 npm 包的枢纽, 和 HTML 文档中的 <head> 区域用来描述网页的配置信息(元数据)一样,它存储项目的相关信息。 它由单个 JSON 对象组成,并以键值对的形式存储项目信息, 且至少包含两个必填字段:“name”和“version”——但是最好提供有关项目的其他信息,这将对用户或者维护者有所帮助。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
如果能找到项目的文件树,那么可以在文件树的最外层找到 package.json, 在接下来的几个挑战中将完善这个文件。
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
在这个文件中最常见的信息之一是 `author` 字段, 它说明了项目的创建者,它可以是字符串,也可以是带有联系人详细信息的对象。 对于较大的项目,建议使用对象;但是在我们的项目中,一个简单的字符串就够了,比如下面的例子:
|
||||
The `package.json` file is the center of any Node.js project or npm package. It stores information about your project, similar to how the <head> section of an HTML document describes the content of a webpage. It consists of a single JSON object where information is stored in key-value pairs. There are only two required fields; "name" and "version", but it’s good practice to provide additional information about your project that could be useful to future users or maintainers.
|
||||
|
||||
If you look at the file tree of your project, you will find the package.json file on the top level of the tree. This is the file that you will be improving in the next couple of challenges.
|
||||
|
||||
One of the most common pieces of information in this file is the `author` field. It specifies who created the project, and can consist of a string or an object with contact or other details. An object is recommended for bigger projects, but a simple string like the following example will do for this project.
|
||||
|
||||
```json
|
||||
"author": "Jane Doe",
|
||||
@@ -28,13 +34,13 @@ dashedName: how-to-use-package-json-the-core-of-any-node-js-project-or-npm-packa
|
||||
|
||||
# --instructions--
|
||||
|
||||
在项目的 package.json 文件的 `author` 键中添加你的名字。
|
||||
Add your name as the `author` of the project in the package.json file.
|
||||
|
||||
**注意:** 正在修改的是一个 JSON,所有的字段名必须用双引号(")包裹,也必须用逗号(,)分割。
|
||||
**Note:** Remember that you’re writing JSON, so all field names must use double-quotes (") and be separated with a comma (,).
|
||||
|
||||
# --hints--
|
||||
|
||||
package.json 应该有一个有效的“author”键
|
||||
package.json should have a valid "author" key
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,19 +14,25 @@ dashedName: install-and-set-up-mongoose
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-mongomongoose" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成这些挑战。
|
||||
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
在这个挑战中,你将建立一个 MongoDB Atlas 数据库并导入连接到它所需的软件包。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
按照<a href='https://chinese.freecodecamp.org/news/get-started-with-mongodb-atlas/' target="_blank" rel="noopener noreferrer nofollow">这篇教程</a>在 MongoDB Atlas 创建一个托管数据库。
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
In this challenge, you will set up a MongoDB Atlas database and import the required packages to connect to it.
|
||||
|
||||
Follow <a href='https://www.freecodecamp.org/news/get-started-with-mongodb-atlas/' target="_blank" rel="noopener noreferrer nofollow">this tutorial</a> to set up a hosted database on MongoDB Atlas.
|
||||
|
||||
# --instructions--
|
||||
|
||||
`mongoose@^5.11.15` 已添加到你项目的 `package.json` 文件中。 首先,在 `myApp.js` 中请求 mongoose 为 `mongoose`。 接下来,创建一个 `.env` 文件并向其中添加一个 `MONGO_URI` 变量。 变量的值为你的 MongoDB Atlas 数据库 URI。 应用单引号或双引号包裹 URI。请记住,环境变量 `=` 两边不能有空格。 例如,`MONGO_URI='VALUE'`。
|
||||
`mongoose@^5.11.15` has been added to your project’s `package.json` file. First, require mongoose as `mongoose` in `myApp.js`. Next, create a `.env` file and add a `MONGO_URI` variable to it. Its value should be your MongoDB Atlas database URI. Be sure to surround the URI with single or double quotes, and remember that you can't use spaces around the `=` in environment variables. For example, `MONGO_URI='VALUE'`.
|
||||
|
||||
**注意:** 如果你使用的是 Replit,则无法创建 `.env` 文件。 相反,使用内置的 <dfn>SECRETS</dfn> 选项卡来添加变量。 在使用 <em>SECRETS</em> 选项卡时,<em>不要</em>将值括在引号中。
|
||||
**Note:** If you are using Replit, you cannot create a `.env` file. Instead, use the built-in <dfn>SECRETS</dfn> tab to add the variable. <em>Do not</em> surround the values with quotes when using the <em>SECRETS</em> tab.
|
||||
|
||||
完成后,使用以下语法连接到数据库:
|
||||
When you are done, connect to the database using the following syntax:
|
||||
|
||||
```js
|
||||
mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true });
|
||||
@@ -34,7 +40,7 @@ mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true }
|
||||
|
||||
# --hints--
|
||||
|
||||
“mongoose version ^5.11.15” 依赖项应该在 package.json
|
||||
"mongoose version ^5.11.15" dependency should be in package.json
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -54,7 +60,7 @@ mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true }
|
||||
);
|
||||
```
|
||||
|
||||
应使用 “mongoose” 连接数据库。
|
||||
"mongoose" should be connected to a database
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,13 +14,19 @@ dashedName: set-up-a-template-engine
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-advancednode" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成这些挑战。
|
||||
- 使用一个你选择的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
你可以在应用的模版引擎中使用静态模板文件(如那些写在 *Pug* 里的)。 在运行时,模版引擎会用服务端的真实数据替换掉模版文件中的变量, 然后将模版转译成发送给客户端的 HTML 静态文件。 这样可以轻松地构造 HTML 页面,允许在页面直接显示变量内容而不需要从客户端发送 API 请求。
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
`pug@~3.0.0` 已经被安装,并且在你项目的 `package.json` 文件中作为依赖。
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
Express 需要知道你正在使用哪个模板引擎。 Use the `set` method to assign `pug` as the `view engine` property's value:
|
||||
A template engine enables you to use static template files (such as those written in *Pug*) in your app. At runtime, the template engine replaces variables in a template file with actual values which can be supplied by your server. Then it transforms the template into a static HTML file that is sent to the client. This approach makes it easier to design an HTML page and allows for displaying variables on the page without needing to make an API call from the client.
|
||||
|
||||
`pug@~3.0.0` has already been installed, and is listed as a dependency in your `package.json` file.
|
||||
|
||||
Express needs to know which template engine you are using. Use the `set` method to assign `pug` as the `view engine` property's value:
|
||||
|
||||
```javascript
|
||||
app.set('view engine', 'pug');
|
||||
@@ -32,11 +38,11 @@ Finally, use `res.render()` in the route for your home page, passing `index` as
|
||||
|
||||
If all went as planned, your app home page will no longer be blank. Instead, it will display a message indicating you've successfully rendered the Pug template!
|
||||
|
||||
完成以上要求后,请提交你的页面链接。 If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#set-up-a-template-engine-1" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
|
||||
Submit your page when you think you've got it right. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#set-up-a-template-engine-1" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
|
||||
|
||||
# --hints--
|
||||
|
||||
项目中应使用 Pug 作为依赖。
|
||||
Pug should be a dependency.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -51,7 +57,7 @@ async (getUserInput) => {
|
||||
}
|
||||
```
|
||||
|
||||
View 引擎应该是 Pug。
|
||||
View engine should be Pug.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,15 +14,21 @@ dashedName: learn-how-javascript-assertions-work
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-mochachai" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成这些挑战。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
在 `tests/1_unit-tests.js` 文件下 `Basic Assertions` suite 内注释为 `#1` 的地方,将每一个 `assert` 更改为 `assert.isNull` 或 `assert.isNotNull` 以使测试通过(应该返回 `true`)。 不要改变传入断言的参数。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#1` in the `Basic Assertions` suite, change each `assert` to either `assert.isNull` or `assert.isNotNull` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
所有测试都应该通过。
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -36,7 +42,7 @@ dashedName: learn-how-javascript-assertions-work
|
||||
);
|
||||
```
|
||||
|
||||
请为第一个断言选择正确的方法— `isNull` 或 `isNotNull`。
|
||||
You should choose the correct method for the first assertion - `isNull` vs. `isNotNull`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +56,7 @@ dashedName: learn-how-javascript-assertions-work
|
||||
);
|
||||
```
|
||||
|
||||
请为第二个断言选择正确的方法— `isNull` 或 `isNotNull`。
|
||||
You should choose the correct method for the second assertion - `isNull` vs. `isNotNull`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
||||
@@ -14,56 +14,62 @@ dashedName: american-british-translator
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-american-british-english-translator" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目。
|
||||
- 使用您选择的站点生成器来完成项目。 并确保包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
当完成本项目,请确认有一个可以公开访问的正常运行 demo 。 然后将 URL 提交到 `Solution Link` 中。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
- 所有逻辑都可以进入 `/components/translator.js`
|
||||
- 在 `/routes/api.js` 中完成 `/api/translate` 路由
|
||||
- 在 `tests/1_unit-tests.js` 和 `tests/2_functional-tests.js` 中创建所有 unit/functional 测试
|
||||
- 查看 `/components` 中的 JavaScript 文件以获取应用程序应该翻译的条款以及不同的拼写
|
||||
- 在 `.env` 文件中将 `NODE_ENV` 设置为 `test`(没有引号),在 Replit 上运行测试。
|
||||
- 使用 `npm run test` 命令,在 console 运行测试。 按 Ctrl+Shift+P(在 Mac 上是 Cmd+Shift+P),并输入“open shell”,打开 Replit 控制台。
|
||||
- All logic can go into `/components/translator.js`
|
||||
- Complete the `/api/translate` route in `/routes/api.js`
|
||||
- Create all of the unit/functional tests in `tests/1_unit-tests.js` and `tests/2_functional-tests.js`
|
||||
- See the JavaScript files in `/components` for the different spelling and terms your application should translate
|
||||
- To run the tests on Replit, set `NODE_ENV` to `test` without quotes in the `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Replit console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
|
||||
在 `tests/1_unit-tests.js` 中写下以下测试:
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
|
||||
- 将 `Mangoes are my favorite fruit.` 转换成英式英语。
|
||||
- 将 `I ate yogurt for breakfast.` 转换成英式英语。
|
||||
- 将 `We had a party at my friend's condo.` 转换成英式英语。
|
||||
- 将 `Can you toss this in the trashcan for me?` 转换成英式英语。
|
||||
- 将 `The parking lot was full.` 转换成英式英语。
|
||||
- 将 `Like a high tech Rube Goldberg machine.` 转换成英式英语。
|
||||
- 将 `To play hooky means to skip class or work.` 转换成英式英语。
|
||||
- 将 `No Mr. Bond, I expect you to die.` 转换成英式英语。
|
||||
- 将 `Dr. Grosh will see you now.` 转换成英式英语。
|
||||
- 将 `Lunch is at 12:15 today.` 转换成英式英语。
|
||||
- 将 `We watched the footie match for a while.` 转换成美式英语。
|
||||
- 将 `Paracetamol takes up to an hour to work.` 转换成美式英语。
|
||||
- 将 `First, caramelise the onions.` 转换成美式英语。
|
||||
- 将 `I spent the bank holiday at the funfair.` 转换成美式英语。
|
||||
- 将 `I had a bicky then went to the chippy.` 转换成美式英语。
|
||||
- 将 `I've just got bits and bobs in my bum bag.` 转换成美式英语。
|
||||
- 将 `The car boot sale at Boxted Airfield was called off.` 转换成美式英语。
|
||||
- 将 `Have you met Mrs Kalyani?` 转换成美式英语。
|
||||
- 将 `Prof Joyner of King's College, London.` 转换成美式英语。
|
||||
- 将 `Tea time is usually around 4 or 4.30.` 转换成美式英语。
|
||||
- 将 `Mangoes are my favorite fruit.` 里的转换高亮。
|
||||
- 高亮 `I ate yogurt for breakfast.` 里的转换。
|
||||
- 高亮 `We watched the footie match for a while.` 里的转换。
|
||||
- 高亮 `Paracetamol takes up to an hour to work.` 里的转换。
|
||||
- Translate `Mangoes are my favorite fruit.` to British English
|
||||
- Translate `I ate yogurt for breakfast.` to British English
|
||||
- Translate `We had a party at my friend's condo.` to British English
|
||||
- Translate `Can you toss this in the trashcan for me?` to British English
|
||||
- Translate `The parking lot was full.` to British English
|
||||
- Translate `Like a high tech Rube Goldberg machine.` to British English
|
||||
- Translate `To play hooky means to skip class or work.` to British English
|
||||
- Translate `No Mr. Bond, I expect you to die.` to British English
|
||||
- Translate `Dr. Grosh will see you now.` to British English
|
||||
- Translate `Lunch is at 12:15 today.` to British English
|
||||
- Translate `We watched the footie match for a while.` to American English
|
||||
- Translate `Paracetamol takes up to an hour to work.` to American English
|
||||
- Translate `First, caramelise the onions.` to American English
|
||||
- Translate `I spent the bank holiday at the funfair.` to American English
|
||||
- Translate `I had a bicky then went to the chippy.` to American English
|
||||
- Translate `I've just got bits and bobs in my bum bag.` to American English
|
||||
- Translate `The car boot sale at Boxted Airfield was called off.` to American English
|
||||
- Translate `Have you met Mrs Kalyani?` to American English
|
||||
- Translate `Prof Joyner of King's College, London.` to American English
|
||||
- Translate `Tea time is usually around 4 or 4.30.` to American English
|
||||
- Highlight translation in `Mangoes are my favorite fruit.`
|
||||
- Highlight translation in `I ate yogurt for breakfast.`
|
||||
- Highlight translation in `We watched the footie match for a while.`
|
||||
- Highlight translation in `Paracetamol takes up to an hour to work.`
|
||||
|
||||
在 `tests/2_functional-tests.js` 中写下以下测试:
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
|
||||
- 翻译文本字段和本地化字段: POST 请求到 `/api/translate`
|
||||
- 翻译文本字段和无效的本地化字段: POST 请求到 `/api/translate`
|
||||
- 翻译缺失的文本字段: POST 请求到 `/api/translate`
|
||||
- 翻译缺失的本地化字段: POST 请求到 `/api/translate`
|
||||
- 翻译空的文本: POST 请求到 `/api/translate`
|
||||
- 翻译无需翻译的文本: POST 请求到 `/api/translate`
|
||||
- Translation with text and locale fields: POST request to `/api/translate`
|
||||
- Translation with text and invalid locale field: POST request to `/api/translate`
|
||||
- Translation with missing text field: POST request to `/api/translate`
|
||||
- Translation with missing locale field: POST request to `/api/translate`
|
||||
- Translation with empty text: POST request to `/api/translate`
|
||||
- Translation with text that needs no translation: POST request to `/api/translate`
|
||||
|
||||
# --hints--
|
||||
|
||||
我可以提供我自己的项目,而不是示例 URL。
|
||||
I can provide my own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -75,7 +81,7 @@ dashedName: american-british-translator
|
||||
};
|
||||
```
|
||||
|
||||
可以向 `/api/translate` 发送 `POST` 请求,对请求体内的 `text` 文本进行翻译, `locale` 字段可以是 `american-to-british` 或 `british-to-american`。 返回的对象应该包含提交的 `text` 以及翻译的文本 `translation`。
|
||||
You can `POST` to `/api/translate` with a body containing `text` with the text to translate and `locale` with either `american-to-british` or `british-to-american`. The returned object should contain the submitted `text` and `translation` with the translated text.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -103,7 +109,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`/api/translate` 路由应该可以处理用英美方式英语写的时间。 例如,十点半英式英语写为“10.30”,而美式英语写为“10:30”。 `span` 元素应该包裹整个时间字符串,即 `<span class="highlight">10:30</span>`。
|
||||
The `/api/translate` route should handle the way time is written in American and British English. For example, ten thirty is written as "10.30" in British English and "10:30" in American English. The `span` element should wrap the entire time string, i.e. `<span class="highlight">10:30</span>`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -130,7 +136,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`/api/translate` 路由也应该处理美式英语和英式英语中头衔/尊称的缩写方式。 例如,Doctor Wright 在英式英语中缩写为 “Dr Wright”,在美式英语中缩写为 “Dr. Wright"”。 请参阅 `/components/american-to-british-titles.js`,了解程序应当处理的不同标题。
|
||||
The `/api/translate` route should also handle the way titles/honorifics are abbreviated in American and British English. For example, Doctor Wright is abbreviated as "Dr Wright" in British English and "Dr. Wright" in American English. See `/components/american-to-british-titles.js` for the different titles your application should handle.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -157,7 +163,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
将任何翻译过的拼写或条目放在 `<span class="highlight">...</span>` 标签内以使其显示为绿色。
|
||||
Wrap any translated spelling or terms with `<span class="highlight">...</span>` tags so they appear in green.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -185,7 +191,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果缺少一个或多个必填字段,返回 `{ error: 'Required field(s) missing' }`。
|
||||
If one or more of the required fields is missing, return `{ error: 'Required field(s) missing' }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -206,7 +212,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果 `text` 为空,返回 `{ error: 'No text to translate' }`
|
||||
If `text` is empty, return `{ error: 'No text to translate' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -227,7 +233,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果 `locale` 与两个指定的 locales 都不匹配,返回 `{ error: 'Invalid value for locale field' }`。
|
||||
If `locale` does not match one of the two specified locales, return `{ error: 'Invalid value for locale field' }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -249,7 +255,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果 `text` 不需要翻译,返回的 `translation` 值为`"Everything looks good to me!"`。
|
||||
If `text` requires no translation, return `"Everything looks good to me!"` for the `translation` value.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -276,7 +282,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 24 个单元的测试都已完成并通过。 请参阅 `/tests/1_unit-tests.js` 来了解你应该写的测试的预期行为。
|
||||
All 24 unit tests are complete and passing. See `/tests/1_unit-tests.js` for the expected behavior you should write tests for.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -301,7 +307,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 6 项功能测试都已完成并通过。 请参阅 `/tests/2_functional-tests.js` 来了解你应该写的测试的功能。
|
||||
All 6 functional tests are complete and passing. See `/tests/2_functional-tests.js` for the functionality you should write tests for.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,36 +14,42 @@ dashedName: issue-tracker
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-issuetracker" target="_blank" rel="noopener noreferrer nofollow">我们的 Replit 初始化项目</a>来完成你的项目。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
- 在 `/routes/api.js` 中完成必要的路由
|
||||
- 在 `tests/2_functional-tests.js` 中创建所有的功能测试
|
||||
- 复制 `sample.env` 文件到 `.env` 并按需设置变量
|
||||
- 要运行测试,在 `.env` 文件中取消注释 `NODE_ENV=test`
|
||||
- 使用 `npm run test` 命令,在 console 运行测试。 按 Ctrl+Shift+P(在 Mac 上是 Cmd+Shift+P),并输入“open shell”,打开 Replit 控制台。
|
||||
- Complete the necessary routes in `/routes/api.js`
|
||||
- Create all of the functional tests in `tests/2_functional-tests.js`
|
||||
- Copy the `sample.env` file to `.env` and set the variables appropriately
|
||||
- To run the tests uncomment `NODE_ENV=test` in your `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Replit console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
|
||||
在 `tests/2_functional-tests.js` 中编写下以下测试:
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
|
||||
- 用所有字段创建 issue:POST 请求到 `/api/issues/{project}`
|
||||
- 用必填字段创建 issue:POST 请求到 `/api/issues/{project}`
|
||||
- 用缺失必填字段创建 issue:POST 请求到 `/api/issues/{project}`
|
||||
- 查看 project 里的 issue:GET 请求到 `/api/issues/{project}`
|
||||
- 用 filter 过滤 project 里的 issue:GET 请求到 `/api/issues/{project}`
|
||||
- 用多个 filter 过滤 project 里的 issue:GET 请求到 `/api/issues/{project}`
|
||||
- 更新 issue 里的一个字段:PUT 请求到 `/api/issues/{project}`
|
||||
- 更新 issue 里的多个字段:PUT 请求到 `/api/issues/{project}`
|
||||
- 在缺少 `_id` 字段的情况下更新 issue: PUT 请求到 `/api/issues/{project}`
|
||||
- 在没有字段更新的情况下调用更新:PUT 请求到 `/api/issues/{project}`
|
||||
- 传入一个无效的的 `_id` 来调用更新:PUT 请求到 `/api/issues/{project}`
|
||||
- 删除一个 issue:DELETE 请求到 `/api/issues/{project}`
|
||||
- 传入一个无效的的 `_id` 来调用删除:DELETE 请求到 `/api/issues/{project}`
|
||||
- 在缺失 `_id` 的情况下来调用删除:DELETE 请求到 `/api/issues/{project}`
|
||||
- Create an issue with every field: POST request to `/api/issues/{project}`
|
||||
- Create an issue with only required fields: POST request to `/api/issues/{project}`
|
||||
- Create an issue with missing required fields: POST request to `/api/issues/{project}`
|
||||
- View issues on a project: GET request to `/api/issues/{project}`
|
||||
- View issues on a project with one filter: GET request to `/api/issues/{project}`
|
||||
- View issues on a project with multiple filters: GET request to `/api/issues/{project}`
|
||||
- Update one field on an issue: PUT request to `/api/issues/{project}`
|
||||
- Update multiple fields on an issue: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with missing `_id`: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with no fields to update: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with an invalid `_id`: PUT request to `/api/issues/{project}`
|
||||
- Delete an issue: DELETE request to `/api/issues/{project}`
|
||||
- Delete an issue with an invalid `_id`: DELETE request to `/api/issues/{project}`
|
||||
- Delete an issue with missing `_id`: DELETE request to `/api/issues/{project}`
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -51,7 +57,7 @@ dashedName: issue-tracker
|
||||
};
|
||||
```
|
||||
|
||||
可以发送 `POST` 请求到 `/api/issues/{projectname}`,表单数据包含必填字段 `issue_title`、`issue_text`、`created_by` 和可选字段 `assigned_to` 以及 `status_text`。
|
||||
You can send a `POST` request to `/api/issues/{projectname}` with form data containing the required fields `issue_title`, `issue_text`, `created_by`, and optionally `assigned_to` and `status_text`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -73,7 +79,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
`POST` 请求到 `/api/issues/{projectname}` 将返回创建的对象,必须包含所有提交的全部字段。 如果没有填选填字段将作为空字符串返回. 此外,包含 `created_on` (日期/时间)、 `updated_on` (日期/时间)、 `open` (布尔型) `true` 用于打开 - 默认值, `false` 用于关闭, `_id`。
|
||||
The `POST` request to `/api/issues/{projectname}` will return the created object, and must include all of the submitted fields. Excluded optional fields will be returned as empty strings. Additionally, include `created_on` (date/time), `updated_on` (date/time), `open` (boolean, `true` for open - default value, `false` for closed), and `_id`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -107,7 +113,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果发送一个 `POST` 请求到 `/api/issues/{projectname}` 且缺少必填字段,会返回错误 `{ error: 'required field(s) missing' }`。
|
||||
If you send a `POST` request to `/api/issues/{projectname}` without the required fields, returned will be the error `{ error: 'required field(s) missing' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -125,7 +131,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以发送 `GET` 请求到 `/api/issues/{projectname}` 请求所有指定 `projectname` 的 issues 数组,会展示每个 issue 的所有字段。
|
||||
You can send a `GET` request to `/api/issues/{projectname}` for an array of all issues for that specific `projectname`, with all the fields present for each issue.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -172,7 +178,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以发送 `GET` 请求到 `/api/issues/{projectname}` 通过 URL 查询传入字段名和值过滤请求(如, `/api/issues/{project}?open=false`)。 你可以一次通过一个或多个字段/值对。
|
||||
You can send a `GET` request to `/api/issues/{projectname}` and filter the request by also passing along any field and value as a URL query (ie. `/api/issues/{project}?open=false`). You can pass one or more field/value pairs at once.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -213,7 +219,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以发送一个 `PUT` 请求到 `/api/issues/{projectname}` 带有一个 `_id` 以及一个或多个字段进行更新。 成功后, `updated_on` field 应该被更新,返回的应该是 `{ result: 'successfully updated', '_id': _id }`。
|
||||
You can send a `PUT` request to `/api/issues/{projectname}` with an `_id` and one or more fields to update. On success, the `updated_on` field should be updated, and returned should be `{ result: 'successfully updated', '_id': _id }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -248,7 +254,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
当 `PUT` 请求发送给 `/api/issues/{projectname}` 的请求体不包含 `_id` 时应返回`{ error: 'missing _id' }`。
|
||||
When the `PUT` request sent to `/api/issues/{projectname}` does not include an `_id`, the return value is `{ error: 'missing _id' }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -264,7 +270,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
当 `PUT` 请求发送给 `/api/issues/{projectname}` 的请求体不包含任何更新的字段,应返回 `{ error: 'no update field(s) sent', '_id': _id }`。 在任何其他错误,应返回 `{ error: 'could not update', '_id': _id }`。
|
||||
When the `PUT` request sent to `/api/issues/{projectname}` does not include update fields, the return value is `{ error: 'no update field(s) sent', '_id': _id }`. On any other error, the return value is `{ error: 'could not update', '_id': _id }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -294,7 +300,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以发送一个 `DELETE` 请求到 `/api/issues/{projectname}` 带有一个 `_id` 来删除 issue。 如果没有发送 `_id` ,返回值为 `{ error: 'missing _id' }`。 成功后,返回值为 `{ result: 'successfully deleted', '_id': _id }`。 失败时,返回值为 `{ error: 'could not delete', '_id': _id }`。
|
||||
You can send a `DELETE` request to `/api/issues/{projectname}` with an `_id` to delete an issue. If no `_id` is sent, the return value is `{ error: 'missing _id' }`. On success, the return value is `{ result: 'successfully deleted', '_id': _id }`. On failure, the return value is `{ error: 'could not delete', '_id': _id }`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -336,7 +342,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 14 项功能测试都已完成并通过。
|
||||
All 14 functional tests are complete and passing.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,46 +14,52 @@ dashedName: metric-imperial-converter
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-metricimpconverter" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
- 在 `/controllers/convertHandler.js` 中完成必要的转换逻辑
|
||||
- 在 `/routes/api.js` 中完成必要的路由
|
||||
- 复制 `sample.env` 文件到 `.env` 并按需设置变量
|
||||
- 在 `.env` 文件中取消注释 `NODE_ENV=test` 来运行测试
|
||||
- 使用 `npm run test` 命令在 console 中运行测试。 按 Ctrl+Shift+P(在 Mac 上是 Cmd+Shift+P),并输入“open shell”,打开 Replit 控制台。
|
||||
- Complete the necessary conversion logic in `/controllers/convertHandler.js`
|
||||
- Complete the necessary routes in `/routes/api.js`
|
||||
- Copy the `sample.env` file to `.env` and set the variables appropriately
|
||||
- To run the tests uncomment `NODE_ENV=test` in your `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Replit console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
|
||||
在 `tests/1_unit-tests.js` 中写下以下测试:
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
|
||||
- `convertHandler` 应该正确地读取整个数字输入。
|
||||
- `convertHandler` 应该正确地读取十进制数字输入。
|
||||
- `convertHandler` 应该正确地读取一个分数输入。
|
||||
- `convertHandler` 应该正确地读取一个带小数点的分数输入。
|
||||
- `convertHandler` 当输入双分数时应该返回错误 ( `3/2/3`)。
|
||||
- `convertHandler` 在没有提供数字输入时应该默认为 `1`。
|
||||
- `convertHandler` 应该正确地读取每个有效的单位输入。
|
||||
- `convertHandler` 在输入无效单位时应返回错误。
|
||||
- `convertHandler` 在输入有效单位时应返回正确的单位。
|
||||
- `convertHandler` 应该正确返回每个有效输入单位的拼写字符串。
|
||||
- `convertHandler` 应该正确地将 `gal` 转换为 `L`。
|
||||
- `convertHandler` 应该正确地将 `L` 转换为 `gal`。
|
||||
- `convertHandler` 应该正确地将 `mi` 转换为 `km`。
|
||||
- `convertHandler` 应该正确地将 `km` 转换为 `mi`。
|
||||
- `convertHandler` 应该正确地将 `lbs` 转换为 `kg`。
|
||||
- `convertHandler` 应该正确地将 `kg` 转换为 `lbs`。
|
||||
- `convertHandler` should correctly read a whole number input.
|
||||
- `convertHandler` should correctly read a decimal number input.
|
||||
- `convertHandler` should correctly read a fractional input.
|
||||
- `convertHandler` should correctly read a fractional input with a decimal.
|
||||
- `convertHandler` should correctly return an error on a double-fraction (i.e. `3/2/3`).
|
||||
- `convertHandler` should correctly default to a numerical input of `1` when no numerical input is provided.
|
||||
- `convertHandler` should correctly read each valid input unit.
|
||||
- `convertHandler` should correctly return an error for an invalid input unit.
|
||||
- `convertHandler` should return the correct return unit for each valid input unit.
|
||||
- `convertHandler` should correctly return the spelled-out string unit for each valid input unit.
|
||||
- `convertHandler` should correctly convert `gal` to `L`.
|
||||
- `convertHandler` should correctly convert `L` to `gal`.
|
||||
- `convertHandler` should correctly convert `mi` to `km`.
|
||||
- `convertHandler` should correctly convert `km` to `mi`.
|
||||
- `convertHandler` should correctly convert `lbs` to `kg`.
|
||||
- `convertHandler` should correctly convert `kg` to `lbs`.
|
||||
|
||||
在 `tests/2_functional-tests.js` 中写下以下测试:
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
|
||||
- 将有效的输入转换为 `10L`: `GET` 请求到 `/api/convert`。
|
||||
- 转换无效的输如 `32g`: `GET` 请求到 `/api/convert`.
|
||||
- 转换无效的数字,例如 `3/7.2/4kg`: `GET` 请求到 `/api/convert`。
|
||||
- 转换无效的数字和单位如 `3/7.2/4kilomegagram`: `GET` 请求到 `/api/convert`.
|
||||
- 转换时没有数字,例如 `kg`: `GET` 请求到 `/api/convert`。
|
||||
- Convert a valid input such as `10L`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid input such as `32g`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid number such as `3/7.2/4kg`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid number AND unit such as `3/7.2/4kilomegagram`: `GET` request to `/api/convert`.
|
||||
- Convert with no number such as `kg`: `GET` request to `/api/convert`.
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
getUserInput => {
|
||||
@@ -65,13 +71,13 @@ getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
通过 `GET` 请求 `/api/convert`,传入数字和单位的单个参数,可以将其转换。 (提示:通过寻找第一个字符的索引来分割输入,这将标记单位的开始)
|
||||
You can `GET` `/api/convert` with a single parameter containing an accepted number and unit and have it converted. (Hint: Split the input by looking for the index of the first character which will mark the start of the unit)
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
可以将 `'gal'` 转换为 `'L'`,反之亦然。 (1 gal to 3.78541 L)
|
||||
You can convert `'gal'` to `'L'` and vice versa. (1 gal to 3.78541 L)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -94,7 +100,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
可以将 `'lbs'` 转换为 `'kg'`,反之亦然。 (1 lbs to 0.453592 kg)
|
||||
You can convert `'lbs'` to `'kg'` and vice versa. (1 lbs to 0.453592 kg)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -117,7 +123,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
你可以将 `'mi'` 转换为 `'km'` 反之亦然。 (1 mi to 1.60934 km)
|
||||
You can convert `'mi'` to `'km'` and vice versa. (1 mi to 1.60934 km)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -140,7 +146,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
所有输入单位以大写和小写形式都应该被接受,但在 `initUnit` 和 `returnUnit` 中应以小写形式返回,升除外,应将其表示为大写的 `'L'`。
|
||||
All incoming units should be accepted in both upper and lower case, but should be returned in both the `initUnit` and `returnUnit` in lower case, except for liter, which should be represented as an uppercase `'L'`.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -163,7 +169,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
如果测量单位无效,返回将为 `'invalid unit'`。
|
||||
If the unit of measurement is invalid, returned will be `'invalid unit'`.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -176,7 +182,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
如果数字无效,返回将为 `'invalid number'`。
|
||||
If the number is invalid, returned will be `'invalid number'`.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -191,7 +197,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
如果单位和数字都无效,返回将为 `'invalid number and unit'`。
|
||||
If both the unit and number are invalid, returned will be `'invalid number and unit'`.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -209,7 +215,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
可以在参数中使用分数、小数或小数分数 (例如 5, 1/2, 2.5/6),如果没有提供任何内容,则默认值为 1。
|
||||
You can use fractions, decimals or both in the parameter (ie. 5, 1/2, 2.5/6), but if nothing is provided it will default to 1.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -240,7 +246,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
返回将包含 `initNum`、`initUnit`、`returnNum`、`returnUnit` 和 `string` 拼写单位格式 `'{initNum} {initUnitString} converts to {returnNum} {returnUnitString}'` 结果四舍五入为 5 小数。
|
||||
Your return will consist of the `initNum`, `initUnit`, `returnNum`, `returnUnit`, and `string` spelling out units in the format `'{initNum} {initUnitString} converts to {returnNum} {returnUnitString}'` with the result rounded to 5 decimals.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -257,7 +263,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 16 个单元的测试都已完成并通过。
|
||||
All 16 unit tests are complete and passing.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -282,7 +288,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 5 项功能测试都已完成并通过。
|
||||
All 5 functional tests are complete and passing.
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
|
||||
@@ -14,7 +14,13 @@ dashedName: personal-library
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-library" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -25,7 +31,7 @@ dashedName: personal-library
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You can provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -35,7 +41,7 @@ dashedName: personal-library
|
||||
};
|
||||
```
|
||||
|
||||
可以发送 <b>POST</b> 请求到 `/api/books`,带有 `title` 作为表单数据的一部分,来添加一本书。 返回的响应将是一个包含 `title` 和唯一的 `_id` 作为键的对象。 如果 `title` 未包含在请求中,返回的响应应该是字符串 `missing required field title`。
|
||||
You can send a <b>POST</b> request to `/api/books` with `title` as part of the form data to add a book. The returned response will be an object with the `title` and a unique `_id` as keys. If `title` is not included in the request, the returned response should be the string `missing required field title`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -56,7 +62,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以向 `/api/books` 发送 <b>GET</b> 请求,并返回代表所有书的 JSON 响应。 JSON 响应应该是一个包含有 `title`、`_id` 和 `commentcount` 属性的对象数组 。
|
||||
You can send a <b>GET</b> request to `/api/books` and receive a JSON response representing all the books. The JSON response will be an array of objects with each object (book) containing `title`, `_id`, and `commentcount` properties.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -84,7 +90,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以发送 <b>GET</b> 请求到 `/api/books/{_id}` 来检索一本书的单个对象,返回属性 `title`、`_id` 和 `comments` 数组 (如果没有评论,则展示空数组)。 如果找不到书, 返回字符串 `no book exists`。
|
||||
You can send a <b>GET</b> request to `/api/books/{_id}` to retrieve a single object of a book containing the properties `title`, `_id`, and a `comments` array (empty array if no comments present). If no book is found, return the string `no book exists`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -108,7 +114,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以发送一个 <b>POST</b> 请求,其中包含 `comment` 作为表单正文数据,请求到 `/api/books/{_id}` 以便将评论添加到书中。 返回的响应将是书对象,在先前测试中 <b>GET</b> `/api/books/{_id}` 类似。 如果请求中没有包含 `comment` ,返回字符串 `missing required field comment`。 如果找不到书, 返回字符串 `no book exists`。
|
||||
You can send a <b>POST</b> request containing `comment` as the form body data to `/api/books/{_id}` to add a comment to a book. The returned response will be the books object similar to <b>GET</b> `/api/books/{_id}` request in an earlier test. If `comment` is not included in the request, return the string `missing required field comment`. If no book is found, return the string `no book exists`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -146,7 +152,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以向 `/api/books/{_id}` 发送 <b>DELETE</b> 请求,从收藏中删除一本书。 如果成功,返回的响应将是字符串 `delete successful`。 如果找不到书, 返回字符串 `no book exists`。
|
||||
You can send a <b>DELETE</b> request to `/api/books/{_id}` to delete a book from the collection. The returned response will be the string `delete successful` if successful. If no book is found, return the string `no book exists`.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -170,7 +176,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以向 `/api/books` 发送 <b>DELETE</b> 请求来删除数据库中的所有书籍。 The returned response will be the string `complete delete successful` if successful.
|
||||
You can send a <b>DELETE</b> request to `/api/books` to delete all books in the database. The returned response will be the string `complete delete successful` if successful.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -187,7 +193,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 10 项功能测试都已完成并通过。
|
||||
All 10 functional tests required are complete and passing.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -14,54 +14,60 @@ dashedName: sudoku-solver
|
||||
- 使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-project-sudoku-solver" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 上的初始化项目</a>来完成你的项目。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
If you use Replit, follow these steps to set up the project:
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
|
||||
# --instructions--
|
||||
|
||||
- 所有解谜逻辑都可以进入 `/controllers/sudoku-solver.js`
|
||||
- `validate` 函数应该使用给定的解谜字符串,然后检查它是否是 81 个有效的输入字符。
|
||||
- `check` 函数应对棋盘的 *current* 进行验证。
|
||||
- `solve` 函数应该处理任何给定的解谜字符串,而不仅仅是测试输入和解决方法。 你需要写出解决这个问题的逻辑。
|
||||
- 所有路由逻辑都可以进入 `/routes/api.js`
|
||||
- 阅读 `/controllers` 中的 `puzzle-strings.js` 文件来了解一些应用程序应该解决的示例谜题
|
||||
- 在 `.env` 文件中将 `NODE_ENV` 设置为 `test` (没有引号),运行这个页面的挑战测试。
|
||||
- 使用 `npm run test` 命令在 console 中运行测试。 按 Ctrl+Shift+P(在 Mac 上是 Cmd+Shift+P),并输入“open shell”,打开 Replit 控制台。
|
||||
- All puzzle logic can go into `/controllers/sudoku-solver.js`
|
||||
- The `validate` function should take a given puzzle string and check it to see if it has 81 valid characters for the input.
|
||||
- The `check` functions should be validating against the *current* state of the board.
|
||||
- The `solve` function should handle solving any given valid puzzle string, not just the test inputs and solutions. You are expected to write out the logic to solve this.
|
||||
- All routing logic can go into `/routes/api.js`
|
||||
- See the `puzzle-strings.js` file in `/controllers` for some sample puzzles your application should solve
|
||||
- To run the challenge tests on this page, set `NODE_ENV` to `test` without quotes in the `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Replit console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
|
||||
在 `tests/1_unit-tests.js` 中写下以下测试:
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
|
||||
- 逻辑处理 81 个字符的解谜字符串
|
||||
- 逻辑处理无效的解谜字符串 (不是 1-9 或 `.`)
|
||||
- 逻辑处理一个长度不是 81 个字符的解谜字符串
|
||||
- 逻辑处理有效行的位置
|
||||
- 逻辑处理无效行的位置
|
||||
- 逻辑处理一个有效的列位置
|
||||
- 逻辑处理无效列位置
|
||||
- 逻辑处理一个有效的区域 (3x3 网格)
|
||||
- 逻辑处理一个无效的区域 (3x3 网格)
|
||||
- 有效解谜字符串通过 solver
|
||||
- 无效解谜字符串无法通过 solver
|
||||
- Solver 返回一个不完整谜题的的预期解决方案
|
||||
- Logic handles a valid puzzle string of 81 characters
|
||||
- Logic handles a puzzle string with invalid characters (not 1-9 or `.`)
|
||||
- Logic handles a puzzle string that is not 81 characters in length
|
||||
- Logic handles a valid row placement
|
||||
- Logic handles an invalid row placement
|
||||
- Logic handles a valid column placement
|
||||
- Logic handles an invalid column placement
|
||||
- Logic handles a valid region (3x3 grid) placement
|
||||
- Logic handles an invalid region (3x3 grid) placement
|
||||
- Valid puzzle strings pass the solver
|
||||
- Invalid puzzle strings fail the solver
|
||||
- Solver returns the expected solution for an incomplete puzzle
|
||||
|
||||
在 `tests/2_functional-tests.js` 中编写下以下测试:
|
||||
Write the following tests in `tests/2_functional-tests.js`
|
||||
|
||||
- 用有效的解谜字符串解决一个谜题:POST 请求到 `/api/solve`
|
||||
- 用缺失的解谜字符串解决一个谜题:POST 请求到 `/api/solve`
|
||||
- 用无效字符解决一个谜题:POST 请求到 `/api/solve`
|
||||
- 用不正确的长度解决一个谜题:POST 请求到 `/api/solve`
|
||||
- 解决一个无法解决的谜题:POST 请求到 `/api/solve`
|
||||
- 检查所有字段的解谜位置:POST 请求到 `/api/check`
|
||||
- 用单个位置冲突检查解谜位置:POST 请求到 `/api/check`
|
||||
- 检查一个有多个位置冲突的解谜位置: POST 请求到 `/api/check`
|
||||
- 检查与所有位置冲突的解谜位置: POST 请求到 `/api/check`
|
||||
- 检查缺失所需字段的解谜位置:POST 请求到 `/api/check`
|
||||
- 检查一个有无效字符的解谜位置: POST 请求到 `/api/check`
|
||||
- 检查不正确长度的解谜位置:POST 请求到 `/api/check`
|
||||
- 检查一个无效的放置坐标的解谜位置:POST 请求到 `/api/check`
|
||||
- 检查具有无效的放置值的解谜位置:POST 请求到 `/api/check`
|
||||
- Solve a puzzle with valid puzzle string: POST request to `/api/solve`
|
||||
- Solve a puzzle with missing puzzle string: POST request to `/api/solve`
|
||||
- Solve a puzzle with invalid characters: POST request to `/api/solve`
|
||||
- Solve a puzzle with incorrect length: POST request to `/api/solve`
|
||||
- Solve a puzzle that cannot be solved: POST request to `/api/solve`
|
||||
- Check a puzzle placement with all fields: POST request to `/api/check`
|
||||
- Check a puzzle placement with single placement conflict: POST request to `/api/check`
|
||||
- Check a puzzle placement with multiple placement conflicts: POST request to `/api/check`
|
||||
- Check a puzzle placement with all placement conflicts: POST request to `/api/check`
|
||||
- Check a puzzle placement with missing required fields: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid characters: POST request to `/api/check`
|
||||
- Check a puzzle placement with incorrect length: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid placement coordinate: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid placement value: POST request to `/api/check`
|
||||
|
||||
# --hints--
|
||||
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
You should provide your own project, not the example URL.
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -70,7 +76,7 @@ dashedName: sudoku-solver
|
||||
};
|
||||
```
|
||||
|
||||
可以发送 `POST` 请求到 `/api/solve`,使用包含 `puzzle` 的表单数据这将是一个包含数字 (1-9) 和点号的字符串组合,`.` 表示空格。 返回的对象将包含一个 `solution` 属性与解决的谜题。
|
||||
You can `POST` `/api/solve` with form data containing `puzzle` which will be a string containing a combination of numbers (1-9) and periods `.` to represent empty spaces. The returned object will contain a `solution` property with the solved puzzle.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -89,7 +95,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/solve` 的对象缺失 `puzzle`,返回的值将是 `{ error: 'Required field missing' }`
|
||||
If the object submitted to `/api/solve` is missing `puzzle`, the returned value will be `{ error: 'Required field missing' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -107,7 +113,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/solve` 谜题包含非数字或点号的值。 返回的值将是 `{ error: 'Invalid characters in puzzle' }`
|
||||
If the puzzle submitted to `/api/solve` contains values which are not numbers or periods, the returned value will be `{ error: 'Invalid characters in puzzle' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -125,7 +131,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/solve` 的谜题大于或小于 81 个字符, 返回的值将是 `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
If the puzzle submitted to `/api/solve` is greater or less than 81 characters, the returned value will be `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -147,7 +153,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/solve` 的谜题无效或无法解决, 返回的值将是 `{ error: 'Puzzle cannot be solved' }`
|
||||
If the puzzle submitted to `/api/solve` is invalid or cannot be solved, the returned value will be `{ error: 'Puzzle cannot be solved' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -165,7 +171,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
可以发送 `POST` 请求到 `/api/check`,包含 `puzzle`、`coordinate` 和 `value` 的对象,其中 `coordinate` 是表示行的字母 A-I,后跟表示列的数字 1-9,而 `value` 是 1-9 的数字。
|
||||
You can `POST` to `/api/check` an object containing `puzzle`, `coordinate`, and `value` where the `coordinate` is the letter A-I indicating the row, followed by a number 1-9 indicating the column, and `value` is a number from 1-9.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -184,7 +190,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
发送 `POST` 请求到 `/api/check`,返回值是一个包含 `valid` 属性的对象,如果数字可能放置在提供的坐标中则是 `true`,否则是`false`。 如果错误,返回的对象还将包含一个 `conflict` 属性,它是一个字符串 `"row"`、`"column"`, 和/或 取决于哪个区域使位置无效的`"region"` 。
|
||||
The return value from the `POST` to `/api/check` will be an object containing a `valid` property, which is `true` if the number may be placed at the provided coordinate and `false` if the number may not. If false, the returned object will also contain a `conflict` property which is an array containing the strings `"row"`, `"column"`, and/or `"region"` depending on which makes the placement invalid.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -207,7 +213,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/check` 的 `value` 已放置在该 `coordinate` 上的 `puzzle`中,如果 `value` 不冲突,则返回的是 `valid` 属性为 `true` 的对象。
|
||||
If `value` submitted to `/api/check` is already placed in `puzzle` on that `coordinate`, the returned value will be an object containing a `valid` property with `true` if `value` is not conflicting.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -226,7 +232,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/check` 的谜题包含非数字或点号的值。 返回的值将是 `{ error: 'Invalid characters in puzzle' }`
|
||||
If the puzzle submitted to `/api/check` contains values which are not numbers or periods, the returned value will be `{ error: 'Invalid characters in puzzle' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -246,7 +252,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/check` 的谜题大于或小于 81 个字符, 返回的值将是 `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
If the puzzle submitted to `/api/check` is greater or less than 81 characters, the returned value will be `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -270,7 +276,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/check` 的对象缺失 `puzzle`、`coordinate` 或 `value`,那么返回的值将是 `{ error: 'Required field(s) missing' }`。
|
||||
If the object submitted to `/api/check` is missing `puzzle`, `coordinate` or `value`, the returned value will be `{ error: 'Required field(s) missing' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -302,7 +308,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `api/check` 的坐标不指向现有的网格单元格, 返回的值将是 `{ error: 'Invalid coordinate'}`
|
||||
If the coordinate submitted to `api/check` does not point to an existing grid cell, the returned value will be `{ error: 'Invalid coordinate'}`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -324,7 +330,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/check` 的 `value` 不是一个介于 1 到 9 之间的数字,则返回的值将是 `{ error: 'Invalid value' }`。
|
||||
If the `value` submitted to `/api/check` is not a number between 1 and 9, the returned value will be `{ error: 'Invalid value' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -346,7 +352,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 12 个单元的测试都已完成并通过。 请参阅 `/tests/1_unit-tests.js` 来了解你应该写的测试的预期行为。
|
||||
All 12 unit tests are complete and passing. See `/tests/1_unit-tests.js` for the expected behavior you should write tests for.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -371,7 +377,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
所有 14 项功能测试都已完成并通过。 请参阅 `/tests/2_functional-tests.js` 来了解你应该编写的测试的功能。
|
||||
All 14 functional tests are complete and passing. See `/tests/2_functional-tests.js` for the expected functionality you should write tests for.
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: arithmetic-formatter
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-arithmetic-formatter" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
小学生经常把算术题垂直排列,这样更容易解决。 例如,“235 + 52” 变成:
|
||||
@@ -58,16 +63,16 @@ arithmetic_arranger(["32 + 8", "1 - 3801", "9999 + 9999", "523 - 49"], True)
|
||||
如果提供的问题格式正确,该函数将返回正确的转换,否则,它将 **返回** 一个 **字符串** 来描述对用户有意义的错误。
|
||||
|
||||
|
||||
- 会返回错误的情况:
|
||||
- 如果提供给函数的 **问题过多**。 限制为 **五个**,更多的将返回: `Error: Too many problems.`
|
||||
- 函数可以接受的运算符是 **加法** 和 **减法** 。 乘法和除法将返回错误。 本要点中未提及的其他运算符将不需要进行测试。 返回的错误将是: `Error: Operator must be '+' or '-'.`
|
||||
- 每个数字(操作数)应该只包含数字。 否则,该函数将返回: `Error: Numbers must only contain digits.`
|
||||
- 每个操作数(也就是运算符两侧的数字)的宽度最多为四位。 否则,返回的错误字符串将为: `Error: Numbers cannot be more than four digits.`
|
||||
- 如果用户提供了正确格式的问题,返回的转换将遵循以下规则:
|
||||
- 操作符和两个操作数中最长的一个之间应该有一个空格,操作符将与第二个操作数在同一行,两个操作数的顺序与提供的相同(第一个是上面的,第二个是下面的)。
|
||||
- 数字应该右对齐。
|
||||
- 每个问题之间应该有四个空格。
|
||||
- 每个问题的底部都应该有破折号。 破折号应该单独沿着每个问题的整个长度延伸。 (上面的例子展示了这应该是什么样子。)
|
||||
- Situations that will return an error:
|
||||
- If there are **too many problems** supplied to the function. The limit is **five**, anything more will return: `Error: Too many problems.`
|
||||
- The appropriate operators the function will accept are **addition** and **subtraction**. Multiplication and division will return an error. Other operators not mentioned in this bullet point will not need to be tested. The error returned will be: `Error: Operator must be '+' or '-'.`
|
||||
- Each number (operand) should only contain digits. Otherwise, the function will return: `Error: Numbers must only contain digits.`
|
||||
- Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be: `Error: Numbers cannot be more than four digits.`
|
||||
- If the user supplied the correct format of problems, the conversion you return will follow these rules:
|
||||
- There should be a single space between the operator and the longest of the two operands, the operator will be on the same line as the second operand, both operands will be in the same order as provided (the first will be the top one and the second will be the bottom).
|
||||
- Numbers should be right-aligned.
|
||||
- There should be four spaces between each problem.
|
||||
- There should be dashes at the bottom of each problem. The dashes should run along the entire length of each problem individually. (The example above shows what this should look like.)
|
||||
|
||||
## 开发
|
||||
|
||||
|
||||
@@ -10,21 +10,26 @@ dashedName: budget-app
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-budget-app" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
完成 `budget.py` 中的 `Category` 类。 它应该能够根据不同的预算类别实例化对象,例如 *食物* 、 *服装* 和 *娱乐* 。 创建对象时,它们以类别的名称传递。 该类应该有一个名为 `ledger` 的实例变量,它是一个列表。 该类还应包含以下方法:
|
||||
|
||||
- 接受金额和描述的 `deposit` 方法。 如果没有给出描述,它应该默认为一个空字符串。 该方法应以 `{"amount": amount, "description": description}` 的形式将对象附加到账本列表。
|
||||
- `withdraw` 方法类似于 `deposit` 方法,但传入的金额应作为负数存储在分类帐中。 如果没有足够的资金,则不应向分类帐添加任何内容。 如果取款发生,此方法应返回 `True`,否则返回 `False`。
|
||||
- `get_balance` 方法,根据发生的存款和取款返回预算类别的当前余额。
|
||||
- 一个 `transfer` 方法,它接受一个金额和另一个预算类别作为参数。 该方法应添加带有金额和描述“Transfer to [目标预算类别]”的提款。 然后,该方法应将存款添加到其他预算类别,其金额和描述为“Transfer from [来源预算类别]”。 如果没有足够的资金,则不应向任一分类帐添加任何内容。 如果转账发生,此方法应返回 `True`,否则返回 `False`。
|
||||
- 接受金额作为参数的 `check_funds` 方法。 如果金额大于预算类别的余额,则返回 `False`,否则返回 `True`。 `withdraw` 方法和 `transfer` 方法都应该使用此方法。
|
||||
- A `deposit` method that accepts an amount and description. If no description is given, it should default to an empty string. The method should append an object to the ledger list in the form of `{"amount": amount, "description": description}`.
|
||||
- A `withdraw` method that is similar to the `deposit` method, but the amount passed in should be stored in the ledger as a negative number. If there are not enough funds, nothing should be added to the ledger. This method should return `True` if the withdrawal took place, and `False` otherwise.
|
||||
- A `get_balance` method that returns the current balance of the budget category based on the deposits and withdrawals that have occurred.
|
||||
- A `transfer` method that accepts an amount and another budget category as arguments. The method should add a withdrawal with the amount and the description "Transfer to [Destination Budget Category]". The method should then add a deposit to the other budget category with the amount and the description "Transfer from [Source Budget Category]". If there are not enough funds, nothing should be added to either ledgers. This method should return `True` if the transfer took place, and `False` otherwise.
|
||||
- A `check_funds` method that accepts an amount as an argument. It returns `False` if the amount is greater than the balance of the budget category and returns `True` otherwise. This method should be used by both the `withdraw` method and `transfer` method.
|
||||
|
||||
打印预算对象时,它应显示:
|
||||
|
||||
- 30 个字符的标题行,类别名称居中在一行 `*` 字符中。
|
||||
- 分类帐中的项目列表。 每行应显示描述和金额。 应显示描述的前 23 个字符,然后是金额。 金额应右对齐,包含两位小数,最多显示 7 个字符。
|
||||
- 一行显示类别总数。
|
||||
- A title line of 30 characters where the name of the category is centered in a line of `*` characters.
|
||||
- A list of the items in the ledger. Each line should show the description and amount. The first 23 characters of the description should be displayed, then the amount. The amount should be right aligned, contain two decimal places, and display a maximum of 7 characters.
|
||||
- A line displaying the category total.
|
||||
|
||||
下面是一个输出示例:
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: polygon-area-calculator
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-polygon-area-calculator" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
在这个项目中,你将使用面向对象的编程来创建 Rectangle(矩形) 类和 Square(正方形) 类。 Square 类应该是 Rectangle 的子类,并继承方法和属性。
|
||||
@@ -20,11 +25,11 @@ dashedName: polygon-area-calculator
|
||||
|
||||
- `set_width`
|
||||
- `set_height`
|
||||
- `get_area`:返回面积(`width * height`)
|
||||
- `get_perimeter`:返回周长(`2 * width + 2 * height`)
|
||||
- `get_diagonal`:返回对角线 (`(width ** 2 + height ** 2) ** .5`)
|
||||
- `get_picture`:返回一个字符串,该字符串使用包含“\*”的行来表示形状。 行数应等于高度,每行中“\*”的数量应等于宽度。 每行末尾应该有一个新行 (`\n`)。 如果宽度或高度大于 50,则应返回字符串:“Too big for picture.”。
|
||||
- `get_amount_inside`:以另一个形状(正方形或矩形)作为参数。 返回传入的形状可以装进该形状的次数(没有旋转)。 例如,一个宽为 4,高为 8 的矩形可以放入两个边长为 4 的正方形。
|
||||
- `get_area`: Returns area (`width * height`)
|
||||
- `get_perimeter`: Returns perimeter (`2 * width + 2 * height`)
|
||||
- `get_diagonal`: Returns diagonal (`(width ** 2 + height ** 2) ** .5`)
|
||||
- `get_picture`: Returns a string that represents the shape using lines of "\*". The number of lines should be equal to the height and the number of "\*" in each line should be equal to the width. There should be a new line (`\n`) at the end of each line. If the width or height is larger than 50, this should return the string: "Too big for picture.".
|
||||
- `get_amount_inside`: Takes another shape (square or rectangle) as an argument. Returns the number of times the passed in shape could fit inside the shape (with no rotations). For instance, a rectangle with a width of 4 and a height of 8 could fit in two squares with sides of 4.
|
||||
|
||||
另外,如果一个 Rectangle 实例被表示为一个字符串,它应该看起来像: `Rectangle(width=5, height=10)`
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@ dashedName: probability-calculator
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-probability-calculator" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
# --instructions--
|
||||
|
||||
假设有一顶帽子,里面有 5 个蓝球、4 个红球和 2 个绿球。 随机抽取的 4 个球中至少包含 1 个红球和 2 个绿球的概率是多少? 虽然可以使用高等数学来计算概率,但更简单的方法是编写一个程序来执行大量实验来估计近似概率。
|
||||
@@ -30,10 +35,10 @@ hat3 = Hat(red=5, orange=4, black=1, blue=0, pink=2, striped=9)
|
||||
|
||||
接下来,在 `prob_calculator.py`(不是在 `Hat` 类中)创建一个 `experiment` 函数。 此函数应接受以下参数:
|
||||
|
||||
- `hat`:一个包含球的帽子对象,应该在函数内复制。
|
||||
- `expected_balls`:一个对象,指示尝试从帽子中抽取的确切球组以进行实验。 例如,要确定从帽子中抽取 2 个蓝球和 1 个红球的概率,将 `expected_balls` 设置为 `{"blue":2, "red":1}`。
|
||||
- `num_balls_drawn`:每次实验中从帽子中抽出的球数。
|
||||
- `num_experiments`:要执行的实验数量。 (进行的实验越多,近似概率就越准确。)
|
||||
- `hat`: A hat object containing balls that should be copied inside the function.
|
||||
- `expected_balls`: An object indicating the exact group of balls to attempt to draw from the hat for the experiment. For example, to determine the probability of drawing 2 blue balls and 1 red ball from the hat, set `expected_balls` to `{"blue":2, "red":1}`.
|
||||
- `num_balls_drawn`: The number of balls to draw out of the hat in each experiment.
|
||||
- `num_experiments`: The number of experiments to perform. (The more experiments performed, the more accurate the approximate probability will be.)
|
||||
|
||||
`experiment` 函数应该返回一个概率。
|
||||
|
||||
|
||||
@@ -10,13 +10,17 @@ dashedName: time-calculator
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-time-calculator" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
# --instructions--
|
||||
|
||||
编写一个名为 `add_time` 的函数,它接受两个必需参数和一个可选参数:
|
||||
|
||||
- 12 小时制的开始时间(以 AM 或 PM 结束)
|
||||
- 指示小时数和分钟数的持续时间
|
||||
- (可选)一周的开始日期,不区分大小写
|
||||
- a start time in the 12-hour clock format (ending in AM or PM)
|
||||
- a duration time that indicates the number of hours and minutes
|
||||
- (optional) a starting day of the week, case insensitive
|
||||
|
||||
该函数应将持续时间添加到开始时间并返回结果。
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: demographic-data-analyzer
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-demographic-data-analyzer" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我们仍在开发 Python 课程的交互式教学部分。 目前,你可以在 YouTube 上通过 freeCodeCamp.org 上传的一些视频学习这个项目相关的知识。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">给所有人的 Python 课程</a>(14 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a> (14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析数据</a>(10 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -32,15 +37,15 @@ dashedName: demographic-data-analyzer
|
||||
|
||||
你必须使用 Pandas 来回答以下问题:
|
||||
|
||||
- 这个数据集中每个种族有多少人? 这应该是一个以种族名称作为索引标签的 Pandas 系列。 (`race` 栏)
|
||||
- 男性的平均年龄是多少?
|
||||
- 拥有学士学位的人的百分比是多少?
|
||||
- 受过高等教育(`Bachelors`, `Masters`, or `Doctorate`)收入超过 50K 的人占多大比例?
|
||||
- 没有受过高等教育的人的收入超过 50K 的比例是多少?
|
||||
- 一个人每周最少工作多少小时?
|
||||
- 每周工作最少小时数的人中有多少人的工资超过 50K?
|
||||
- 哪个国家/地区的收入 >50K 的人口比例最高,该比例是多少?
|
||||
- 确定印度收入 >50K 的人最受欢迎的职业。
|
||||
- How many people of each race are represented in this dataset? This should be a Pandas series with race names as the index labels. (`race` column)
|
||||
- What is the average age of men?
|
||||
- What is the percentage of people who have a Bachelor's degree?
|
||||
- What percentage of people with advanced education (`Bachelors`, `Masters`, or `Doctorate`) make more than 50K?
|
||||
- What percentage of people without advanced education make more than 50K?
|
||||
- What is the minimum number of hours a person works per week?
|
||||
- What percentage of the people who work the minimum number of hours per week have a salary of more than 50K?
|
||||
- What country has the highest percentage of people that earn >50K and what is that percentage?
|
||||
- Identify the most popular occupation for those who earn >50K in India.
|
||||
|
||||
使用文件 `demographic_data_analyzer` 中的启动代码。 更新代码,以便将所有设置为“None”的变量设置为适当的计算或代码。 将所有小数四舍五入到最接近的十分之一。
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: mean-variance-standard-deviation-calculator
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-mean-variance-standard-deviation-calculator" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我们仍在开发 Python 课程的交互式教学部分。 目前,你可以在 YouTube 上通过 freeCodeCamp.org 上传的一些视频学习这个项目相关的知识。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">给所有人的 Python 课程</a>(14 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析数据</a>(10 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: medical-data-visualizer
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-medical-data-visualizer" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我们仍在开发 Python 课程的交互式教学部分。 目前,你可以在 YouTube 上通过 freeCodeCamp.org 上传的一些视频学习这个项目相关的知识。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">给所有人的 Python 课程</a>(14 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析数据</a>(10 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -47,16 +52,16 @@ dashedName: medical-data-visualizer
|
||||
|
||||
在 `medical_data_visualizer.py` 中使用数据完成以下任务:
|
||||
|
||||
- 给数据添加一列 `overweight`。 要确定一个人是否超重,首先通过将他们的体重(公斤)除以他们的身高(米)的平方来计算他们的 BMI。 如果该值 > 25,则此人超重。 使用值 0 表示不超重,使用值 1 表示超重。
|
||||
- 使用 0 表示好的和 1 表示坏,来规范化数据。 如果 `cholesterol` 或 `gluc` 的值为 1,则将值设为 0。 如果值大于 1,则将值设为 1。
|
||||
- 将数据转换为长格式并使用 seaborn 的 `catplot()` 创建一个显示分类特征值计数的图表。 数据集应按“Cardio”拆分,因此每个 `cardio` 值都有一个图表。 该图表应该看起来像 `examples/Figure_1.png`。
|
||||
- 清理数据。 过滤掉以下代表不正确数据的患者段:
|
||||
- 舒张压高于收缩压(使用 `(df['ap_lo'] <= df['ap_hi'])` 保留正确的数据)
|
||||
- 高度小于第 2.5 个百分位数(使用 `(df['height'] >= df['height'].quantile(0.025))` 保留正确的数据)
|
||||
- 身高超过第 97.5 个百分位
|
||||
- 体重小于第 2.5 个百分位
|
||||
- 体重超过第 97.5 个百分位
|
||||
- 使用数据集创建相关矩阵。 使用 seaborn 的 `heatmap()` 绘制相关矩阵。 遮罩上三角。 该图表应类似于 `examples/Figure_2.png`。
|
||||
- Add an `overweight` column to the data. To determine if a person is overweight, first calculate their BMI by dividing their weight in kilograms by the square of their height in meters. If that value is > 25 then the person is overweight. Use the value 0 for NOT overweight and the value 1 for overweight.
|
||||
- Normalize the data by making 0 always good and 1 always bad. If the value of `cholesterol` or `gluc` is 1, make the value 0. If the value is more than 1, make the value 1.
|
||||
- Convert the data into long format and create a chart that shows the value counts of the categorical features using seaborn's `catplot()`. The dataset should be split by 'Cardio' so there is one chart for each `cardio` value. The chart should look like `examples/Figure_1.png`.
|
||||
- Clean the data. Filter out the following patient segments that represent incorrect data:
|
||||
- diastolic pressure is higher than systolic (Keep the correct data with `(df['ap_lo'] <= df['ap_hi'])`)
|
||||
- height is less than the 2.5th percentile (Keep the correct data with `(df['height'] >= df['height'].quantile(0.025))`)
|
||||
- height is more than the 97.5th percentile
|
||||
- weight is less than the 2.5th percentile
|
||||
- weight is more than the 97.5th percentile
|
||||
- Create a correlation matrix using the dataset. Plot the correlation matrix using seaborn's `heatmap()`. Mask the upper triangle. The chart should look like `examples/Figure_2.png`.
|
||||
|
||||
每当变量设置为 `None` 时,请确保将其设置为正确的代码。
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: page-view-time-series-visualizer
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-page-view-time-series-visualizer" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我们仍在开发 Python 课程的交互式教学部分。 目前,你可以在 freeCodeCamp.org 的 YouTube 频道中通过视频学习到这个项目相关的所有知识
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">给所有人的 Python 课程</a>(14 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析数据</a>(10 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -22,11 +27,11 @@ dashedName: page-view-time-series-visualizer
|
||||
|
||||
使用数据完成以下任务:
|
||||
|
||||
- 使用 Pandas 从 “fcc-forum-pageviews.csv” 导入数据。 将索引设置为 `date` 列。
|
||||
- 通过过滤掉页面浏览量位于数据集前 2.5% 或数据集后 2.5% 的日期来清理数据。
|
||||
- 创建一个 `draw_line_plot` 函数,该函数使用 Matplotlib 绘制类似于“examples/Figure_1.png”的折线图。 标题应为 `Daily freeCodeCamp Forum Page Views 5/2016-12/2019`。 x 轴上的标签应为 `Date`,y 轴上的标签应为 `Page Views`。
|
||||
- 创建一个 `draw_bar_plot` 函数,用于绘制类似于“examples/Figure_2.png”的条形图。 它应该显示按年份分组的每个月的平均每日页面浏览量。 图例应显示月份标签并具有 `Months` 标题。 在图表上,x 轴上的标签应为 `Years`,y 轴上的标签应为 `Average Page Views`。
|
||||
- 创建一个 `draw_box_plot` 函数,该函数使用 Seaborn 绘制两个相邻的箱形图,类似于“examples/Figure_3.png”。 这些箱线图应显示值在给定年份或月份内的分布情况以及随时间推移的比较情况。 第一个图表的标题应为 `Year-wise Box Plot (Trend)`,第二个图表的标题应为 `Month-wise Box Plot (Seasonality)`。 确保底部的月份标签从 `Jan` 开始,并且 x 和 y 轴标记正确。 样板文件包括准备数据的命令。
|
||||
- Use Pandas to import the data from "fcc-forum-pageviews.csv". Set the index to the `date` column.
|
||||
- Clean the data by filtering out days when the page views were in the top 2.5% of the dataset or bottom 2.5% of the dataset.
|
||||
- Create a `draw_line_plot` function that uses Matplotlib to draw a line chart similar to "examples/Figure_1.png". The title should be `Daily freeCodeCamp Forum Page Views 5/2016-12/2019`. The label on the x axis should be `Date` and the label on the y axis should be `Page Views`.
|
||||
- Create a `draw_bar_plot` function that draws a bar chart similar to "examples/Figure_2.png". It should show average daily page views for each month grouped by year. The legend should show month labels and have a title of `Months`. On the chart, the label on the x axis should be `Years` and the label on the y axis should be `Average Page Views`.
|
||||
- Create a `draw_box_plot` function that uses Seaborn to draw two adjacent box plots similar to "examples/Figure_3.png". These box plots should show how the values are distributed within a given year or month and how it compares over time. The title of the first chart should be `Year-wise Box Plot (Trend)` and the title of the second chart should be `Month-wise Box Plot (Seasonality)`. Make sure the month labels on bottom start at `Jan` and the x and y axis are labeled correctly. The boilerplate includes commands to prepare the data.
|
||||
|
||||
对于每个图表,请确保使用数据框的副本。 单元测试是在 `test_module.py` 下为你编写的。
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ dashedName: sea-level-predictor
|
||||
|
||||
你将使用<a href="https://replit.com/github/freeCodeCamp/boilerplate-sea-level-predictor" target="_blank" rel="noopener noreferrer nofollow">我们在 Replit 的初始化项目</a>来完成这个项目。
|
||||
|
||||
- Start by importing the project on Replit.
|
||||
- Next, you will see a `.replit` window.
|
||||
- Select `Use run command` and click the `Done` button.
|
||||
|
||||
|
||||
我们仍在开发 Python 课程的交互式教学部分。 目前,你可以在 YouTube 上通过 freeCodeCamp.org 上传的一些视频学习这个项目相关的知识。
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">给所有人的 Python 课程</a>(14 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a>(14 hours)
|
||||
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">如何使用 Python Pandas 分析数据</a>(10 小时)
|
||||
- <a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -22,11 +27,11 @@ dashedName: sea-level-predictor
|
||||
|
||||
使用数据完成以下任务:
|
||||
|
||||
- 使用 Pandas 从 `epa-sea-level.csv` 导入数据。
|
||||
- 使用 matplotlib 创建散点图,使用 `Year` 列作为 x 轴,将 `CSIRO Adjusted Sea Level` 列作为 y 轴。
|
||||
- 使用 `scipy.stats` 中的 `linregress` 函数来获得最佳拟合线的斜率和 y 截距。 在散点图的顶部绘制最佳拟合线。 使线穿过 2050 年以预测 2050 年的海平面上升。
|
||||
- 仅使用数据集中从 2000 年到最近一年的数据绘制一条新的最佳拟合线。 如果上升速度继续与 2000 年一样,则使该线也经过 2050 年以预测 2050 年的海平面上升。
|
||||
- x 标签应为 `Year`,y 标签应为 `Sea Level (inches)`,标题应为 `Rise in Sea Level`。
|
||||
- Use Pandas to import the data from `epa-sea-level.csv`.
|
||||
- Use matplotlib to create a scatter plot using the `Year` column as the x-axis and the `CSIRO Adjusted Sea Level` column as the y-axix.
|
||||
- Use the `linregress` function from `scipy.stats` to get the slope and y-intercept of the line of best fit. Plot the line of best fit over the top of the scatter plot. Make the line go through the year 2050 to predict the sea level rise in 2050.
|
||||
- Plot a new line of best fit just using the data from year 2000 through the most recent year in the dataset. Make the line also go through the year 2050 to predict the sea level rise in 2050 if the rate of rise continues as it has since the year 2000.
|
||||
- The x label should be `Year`, the y label should be `Sea Level (inches)`, and the title should be `Rise in Sea Level`.
|
||||
|
||||
单元测试是在 `test_module.py` 下为你编写的。
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user