-
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
Operators #147
Open
Gabitzzz
wants to merge
13
commits into
javascript-tutorial:master
Choose a base branch
from
Gabitzzz: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
Operators #147
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2759c78
Update solution.md
Gabitzzz ed8131a
Update task.md
Gabitzzz 9d89f2e
Update article.md
Gabitzzz 8cf43af
Update article.md
Gabitzzz bd196df
Update article.md
Gabitzzz 7fcf68d
Update 1-js/02-first-steps/08-operators/4-fix-prompt/solution.md
Gabitzzz 3187282
Update 1-js/02-first-steps/08-operators/4-fix-prompt/solution.md
Gabitzzz ded9060
Update 1-js/02-first-steps/08-operators/4-fix-prompt/task.md
Gabitzzz 2720578
Update 1-js/02-first-steps/08-operators/article.md
Gabitzzz 4ff45cc
Update 1-js/02-first-steps/08-operators/article.md
Gabitzzz 41866b9
Update 1-js/02-first-steps/08-operators/article.md
Gabitzzz bc536b9
Update 1-js/02-first-steps/08-operators/4-fix-prompt/task.md
Gabitzzz 2d28aa6
Update 1-js/02-first-steps/08-operators/article.md
Gabitzzz 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
25 changes: 12 additions & 13 deletions
25
1-js/02-first-steps/08-operators/4-fix-prompt/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,32 +1,31 @@ | ||
The reason is that prompt returns user input as a string. | ||
|
||
So variables have values `"1"` and `"2"` respectively. | ||
Motivul este ca prompt afișeaza inputul utilizatorului ca și un șir. | ||
Gabitzzz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Astfel variable au valorile `"1"` și `"2"` respectiv. | ||
|
||
```js run | ||
let a = "1"; // prompt("First number?", 1); | ||
let b = "2"; // prompt("Second number?", 2); | ||
let a = "1"; // prompt("Primul număr?", 1); | ||
let b = "2"; // prompt("Al doilea număr?", 2); | ||
|
||
alert(a + b); // 12 | ||
``` | ||
|
||
What we should do is to convert strings to numbers before `+`. For example, using `Number()` or prepending them with `+`. | ||
Ce ar trebui noi să facem este să convertim șirurile în numere înainte de `+`. De exemplu, folosind `Number()` sau să le adăugam `+` în față. | ||
|
||
For example, right before `prompt`: | ||
De exemplu, chiar înainte de `prompt`: | ||
|
||
```js run | ||
let a = +prompt("First number?", 1); | ||
let b = +prompt("Second number?", 2); | ||
let a = +prompt("Primul număr?", 1); | ||
let b = +prompt("Al doilea număr?", 2); | ||
|
||
alert(a + b); // 3 | ||
``` | ||
|
||
Or in the `alert`: | ||
Sau în `alert`: | ||
|
||
```js run | ||
let a = prompt("First number?", 1); | ||
let b = prompt("Second number?", 2); | ||
let a = prompt("Primul număr?", 1); | ||
let b = prompt("Al doilea număr?", 2); | ||
|
||
alert(+a + +b); // 3 | ||
``` | ||
|
||
Using both unary and binary `+` in the latest code. Looks funny, doesn't it? | ||
Folosind atât `+` unar și binar în cel mai recent cod. Arată amuzant, nu-i așa? | ||
Gabitzzz marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
După instrucțiuni, trebuie să păstrăm liniile "așa cum sunt". Acest lucru reduce conflictele de
merge
.Sugestie: adaugă o linie goală între linia 1 și 2.