-
Notifications
You must be signed in to change notification settings - Fork 30
Functions #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
deivuss331
merged 7 commits into
javascript-tutorial:master
from
dyrpit:14-function-basics
Dec 16, 2021
Merged
Functions #85
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ea8d3c8
main article and tasks with solutions
dyrpit 3cbea35
changed requested lines
dyrpit 4e21d0e
changed requested lines
dyrpit 190bece
changed requested lines
dyrpit fe0b1dd
changed requested lines
dyrpit c6ba161
changed requested lines
dyrpit 551d348
changed word "zaciemnia" to "przesłania"
dyrpit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
1-js/02-first-steps/14-function-basics/1-if-else-required/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
No difference. | ||
Nie ma żadnej różnicy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
Using a question mark operator `'?'`: | ||
Przy użyciu operatora warunkowego `'?'`: | ||
|
||
```js | ||
function checkAge(age) { | ||
return (age > 18) ? true : confirm('Did parents allow you?'); | ||
return (age > 18) ? true : confirm('Czy rodzice ci pozwolili?'); | ||
} | ||
``` | ||
|
||
Using OR `||` (the shortest variant): | ||
Używając logicznego OR `||` (krótszy wariant): | ||
|
||
```js | ||
function checkAge(age) { | ||
return (age > 18) || confirm('Did parents allow you?'); | ||
return (age > 18) || confirm('Czy rodzice ci pozwolili?'); | ||
} | ||
``` | ||
|
||
Note that the parentheses around `age > 18` are not required here. They exist for better readabilty. | ||
Zwróć uwagę że nawiasy wokół `age > 18` nie są tutaj wymagane. Są tutaj dla lepszej czytelności. |
18 changes: 9 additions & 9 deletions
18
1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
importance: 4 | ||
ważność: 4 | ||
dyrpit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
--- | ||
|
||
# Rewrite the function using '?' or '||' | ||
# Przepisz funkcję używając '?' lub '||' | ||
|
||
The following function returns `true` if the parameter `age` is greater than `18`. | ||
Następująca funkcja zwraca `true` jeżeli parametr `age` jest większy niż `18`. | ||
|
||
Otherwise it asks for a confirmation and returns its result. | ||
W przeciwnym razie prosi o potwierdzenie i zwraca wynik. | ||
|
||
```js | ||
function checkAge(age) { | ||
if (age > 18) { | ||
return true; | ||
} else { | ||
return confirm('Did parents allow you?'); | ||
return confirm('Czy rodzice ci pozwolili?'); | ||
} | ||
} | ||
``` | ||
|
||
Rewrite it, to perform the same, but without `if`, in a single line. | ||
Przepisz ją, aby zachowywała się tak samo, ale bez `if`, w żadnej z lini. | ||
|
||
Make two variants of `checkAge`: | ||
Stwórz dwa warianty `checkAge`: | ||
|
||
1. Using a question mark operator `?` | ||
2. Using OR `||` | ||
1. Przy użyciu operatora warunkowego `?` | ||
2. Używając logicznego OR `||` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
importance: 4 | ||
ważność: 4 | ||
dyrpit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
--- | ||
|
||
# Function pow(x,n) | ||
# Funkcja pow(x,n) | ||
|
||
Write a function `pow(x,n)` that returns `x` in power `n`. Or, in other words, multiplies `x` by itself `n` times and returns the result. | ||
Napisz funkcję `pow(x,n)` która zwraca `x` podniesione do potęgi `n`. Lub, innymi słowy, mnoży `x` przez samą siebie `n` razy i zwraca rezultat. | ||
|
||
```js | ||
pow(3, 2) = 3 * 3 = 9 | ||
pow(3, 3) = 3 * 3 * 3 = 27 | ||
pow(1, 100) = 1 * 1 * ...* 1 = 1 | ||
``` | ||
|
||
Create a web-page that prompts for `x` and `n`, and then shows the result of `pow(x,n)`. | ||
Stwórz stronę internetową która wyświetla okno dialogowe i prosi od podanie `x` oraz `n`, a następnie pokazuje rezultat `pow(x,n)`. | ||
|
||
[demo] | ||
|
||
P.S. In this task the function should support only natural values of `n`: integers up from `1`. | ||
P.S. W tym zadaniu funkcja powinna wspierać jedynie naturalne wartości `n`: liczby całkowite od `1` wzwyż. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.