fix: converted single to triple backticks10 (#36237)
This commit is contained in:
@@ -8,26 +8,30 @@ localeTitle: مشغلون شرطيون شرطيون
|
||||
|
||||
المشغل الثلاثي هو طريقة مدمجة لكتابة if-else داخل تعبير.
|
||||
|
||||
`const thing = (condition) ? <if true> : <if false>;
|
||||
`
|
||||
```js
|
||||
const thing = (condition) ? <if true> : <if false>;
|
||||
```
|
||||
|
||||
على سبيل المثال
|
||||
|
||||
`const cappedInput = input > 50 ? 50 : input // this will cap the input at 50
|
||||
`
|
||||
```js
|
||||
const cappedInput = input > 50 ? 50 : input // this will cap the input at 50
|
||||
```
|
||||
|
||||
### آخر إذا
|
||||
|
||||
يمكنك أيضًا تشغيل مشغلات ثلاثية ، وبهذه الطريقة سيكون لديك سلوك آخر في حالة ما عدا ذلك
|
||||
|
||||
`<first condition> ? <value if first true>
|
||||
: <second condition> ? <value if second is true>
|
||||
: <fallback value>
|
||||
`
|
||||
```js
|
||||
<first condition> ? <value if first true>
|
||||
: <second condition> ? <value if second is true>
|
||||
: <fallback value>
|
||||
```
|
||||
|
||||
> **نصيحة للمحترفين** : كما ترى ، يمكنك تقسيم المشغل الثلاثي على عدة أسطر على سبيل المثال
|
||||
|
||||
`const wealth = housesOwned > 3 ? "rich"
|
||||
: housesOwned > 1 ? "nothing to complain"
|
||||
: "poor"
|
||||
`
|
||||
```
|
||||
const wealth = housesOwned > 3 ? "rich"
|
||||
: housesOwned > 1 ? "nothing to complain"
|
||||
: "poor"
|
||||
```
|
Reference in New Issue
Block a user