Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Translate task 6
  • Loading branch information
Moviss committed Oct 27, 2020
commit 3139b59ac6cb3b79ad9f3a10e4674b0dbb49bc7c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
let num;

do {
num = prompt("Enter a number greater than 100?", 0);
num = prompt("Wprowadź liczbę większą niż 100?", 0);
} while (num <= 100 && num);
```

The loop `do..while` repeats while both checks are truthy:
Pętla `do...while` powtarza się, podczas gdy oba sprawdzenia są prawdziwe:

1. The check for `num <= 100` -- that is, the entered value is still not greater than `100`.
2. The check `&& num` is false when `num` is `null` or a empty string. Then the `while` loop stops too.
1. 1. Sprawdzenie, czy `num <= 100` -- to znaczy, że wprowadzona wartość jest wciąż nie większa niż `100`.
2. Sprawdzanie `&& num` jest fałszywe, gdy `num` ma wartość `null` lub jest pustym stringiem. Wtedy pętla `while` też się zatrzymuje.

P.S. If `num` is `null` then `num <= 100` is `true`, so without the 2nd check the loop wouldn't stop if the user clicks CANCEL. Both checks are required.
P.S. Jeśli `num` ma wartość `null` to `num <= 100` ma wartość `true`, więc bez drugiego sprawdzenia pętla nie zatrzymałaby się, gdyby użytkownik kliknął PRZERWIJ. Oba sprawdzenia są wymagane.
10 changes: 5 additions & 5 deletions 1-js/02-first-steps/18-while-for/6-repeat-until-correct/task.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
importance: 5
ważność: 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not translate YAML metadata


---

# Repeat until the input is correct
# Powtarzaj do momentu, aż wejście będzie prawidłowe

Write a loop which prompts for a number greater than `100`. If the visitor enters another number -- ask them to input again.
Napisz pętlę, która pyta o liczbę większą niż `100`. Jeśli odwiedzający wprowadzi inną liczbę - poproś go o jej ponowne wprowadzenie.

The loop must ask for a number until either the visitor enters a number greater than `100` or cancels the input/enters an empty line.
Pętla musi pytać o liczbę, dopóki użytkownik nie wprowadzi liczby większej niż `100` lub nie anuluje wejścia/wprowadzi pustą linię.

Here we can assume that the visitor only inputs numbers. There's no need to implement a special handling for a non-numeric input in this task.
Tutaj możemy założyć, że odwiedzający wprowadza tylko numery. Nie ma potrzeby implementowania specjalnej obsługi dla nie-numerycznych danych wejściowych w tym zadaniu.

[demo]