-
Notifications
You must be signed in to change notification settings - Fork 31
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
Functions #169
Open
marina-t-itf
wants to merge
7
commits into
javascript-tutorial:master
Choose a base branch
from
marina-t-itf:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Functions #169
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f114998
Functions
marina-t-itf ad10bf3
adjusted
marina-t-itf b6ba903
Merge branch 'master' into master
bogdanbacosca 981af4d
adjusted
marina-t-itf d6ace89
adjusted
marina-t-itf cd59785
ajusted
marina-t-itf 0101de4
Update solution.md
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
4 changes: 2 additions & 2 deletions
4
1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md
This file contains 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,3 +1,3 @@ | ||
No difference! | ||
Nicio diferență! | ||
|
||
In both cases, `return confirm('Did parents allow you?')` executes exactly when the `if` condition is falsy. | ||
In both cases, `return confirm('Did parents allow you?')` executes exactly when the `if` condition is falsy. | ||
This file contains 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/15-function-basics/2-rewrite-function-question-or/solution.md
This file contains 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 `'?'`: | ||
Folosind un operator de semn de întrebare `'?'`: | ||
|
||
```js | ||
function checkAge(age) { | ||
return (age > 18) ? true : confirm('Did parents allow you?'); | ||
return (age > 18) ? true : confirm('Ți-au permis părinții?'); | ||
} | ||
``` | ||
|
||
Using OR `||` (the shortest variant): | ||
Folosind SAU `||` (cea mai scurtă variantă): | ||
|
||
```js | ||
function checkAge(age) { | ||
return (age > 18) || confirm('Did parents allow you?'); | ||
return (age > 18) || confirm('Ți-au permis părinții?'); | ||
} | ||
``` | ||
|
||
Note that the parentheses around `age > 18` are not required here. They exist for better readability. | ||
Rețineți că parantezele din jurul `age > 18` nu sunt necesare aici. Ele există pentru o mai bună lizibilitate. |
This file contains 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 | ||||
---|---|---|---|---|---|---|
|
@@ -2,25 +2,25 @@ importance: 4 | |||||
|
||||||
--- | ||||||
|
||||||
# Rewrite the function using '?' or '||' | ||||||
# Rescrieți funcția folosind '?' sau '||' | ||||||
|
||||||
The following function returns `true` if the parameter `age` is greater than `18`. | ||||||
Următoarea funcție returnează `true` dacă parametrul `age` este mai mare decât `18`. | ||||||
|
||||||
Otherwise it asks for a confirmation and returns its result. | ||||||
În caz contrar aceasta cere o confirmare și îi returnează rezultatul. | ||||||
|
||||||
```js | ||||||
function checkAge(age) { | ||||||
if (age > 18) { | ||||||
return true; | ||||||
} else { | ||||||
return confirm('Did parents allow you?'); | ||||||
return confirm('Ți-au permis părinții?'); | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
Rewrite it, to perform the same, but without `if`, in a single line. | ||||||
Rescrie-l, pentru a efectua la fel, dar fără `if`, într-o singură linie. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Make two variants of `checkAge`: | ||||||
Faceți două variante de `checkAge`: | ||||||
|
||||||
1. Using a question mark operator `?` | ||||||
2. Using OR `||` | ||||||
1. Folosind un operator de semn de întrebare `?` | ||||||
2. Folosind SAU `||` |
This file contains 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 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Netradus