◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
8 changes: 4 additions & 4 deletions 1-js/02-first-steps/10-ifelse/1-if-zero-string/solution.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
**بله اجرا می شود.**

هر رشته به جز رشته خالی (`"0"` خالی نیست!) از نظر منطقی true ارزیابی می شود.

می توانیم این تکه کد را اجرا کنیم و مورد بالا را بررسی کنیم:

```js run
if ("0") {
alert( 'Hello' );
}
```

6 changes: 3 additions & 3 deletions 1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ importance: 5

---

# if (بررسی رشته با مقدار صفر)

آیا `alert` اجرا می شود؟

```js
if ("0") {
alert( 'Hello' );
}
```

8 changes: 4 additions & 4 deletions 1-js/02-first-steps/10-ifelse/2-check-standard/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ importance: 2

---

# The name of JavaScript

Using the `if..else` construct, write the code which asks: 'What is the "official" name of JavaScript?'

If the visitor enters "ECMAScript", then output "Right!", otherwise -- output: "You don't know? ECMAScript!"

![](ifelse_task2.svg)

[demo src="ifelse_task2"]
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/10-ifelse/3-sign/solution.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


```js run
let value = prompt('Type a number', 0);

if (value > 0) {
alert( 1 );
Expand Down
14 changes: 7 additions & 7 deletions 1-js/02-first-steps/10-ifelse/3-sign/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ importance: 2

---

# Show the sign

Using `if..else`, write the code which gets a number via `prompt` and then shows in `alert`:

- `1`, if the value is greater than zero,
- `-1`, if less than zero,
- `0`, if equals zero.

In this task we assume that the input is always a number.

[demo src="if_sign"]
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ importance: 5

---

# Rewrite 'if' into '?'

Rewrite this `if` using the conditional operator `'?'`:

```js
let result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@


```js
let message = (login == 'Employee') ? 'Hello' :
(login == 'Director') ? 'Greetings' :
(login == '') ? 'No login' :
'';
```

16 changes: 8 additions & 8 deletions 1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ importance: 5

---

# Rewrite 'if..else' into '?'

Rewrite `if..else` using multiple ternary operators `'?'`.

For readability, it's recommended to split the code into multiple lines.

```js
let message;

if (login == 'Employee') {
message = 'Hello';
} else if (login == 'Director') {
message = 'Greetings';
} else if (login == '') {
message = 'No login';
} else {
message = '';
}
Expand Down
Loading
Toggle all file notes Toggle all file annotations