Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 228
Basic operators, maths#314
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
5b369957d34563a11a915500d8e5b14e252ef700030b01e8b3fb8d405a008f301716b7470f5f84104623fa1f7d2b83d4b1ec1088aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| The answer is: | ||
| La respuesta es: | ||
| - `a = 4` (multiplied by 2) | ||
| - `x = 5` (calculated as 1 + 4) | ||
| - `a = 4` (multiplicado por 2) | ||
| - `x = 5` (calculado como 1 + 4) | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,32 +1,32 @@ | ||||||||||
| The reason is that prompt returns user input as a string. | ||||||||||
| La razón es que la captura devuelve la entrada del usuario como una cadena. | ||||||||||
| So variables have values `"1"` and `"2"` respectively. | ||||||||||
| Entonces las variables tienen valores `"1"` y `"2"` respectivamente. | ||||||||||
| ```js run | ||||||||||
| let a = "1"; // prompt("First number?", 1); | ||||||||||
| let b = "2"; // prompt("Second number?", 2); | ||||||||||
| let a = "1"; // prompt("Primer número?", 1); | ||||||||||
Member 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
No me gusta la pregunta pero eso no es importante. PEro la apertura para cumplir con la RAE. Collaborator 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
Yo opino que va sin signo interrogativo pues no es una pregunta la que se hace, sino una solicitud Member 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. ¿No pedís con una pregunta? o así: if ( Collaborator 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. De hecho no... Leelo con tono de pregunta. @joaquinelio | ||||||||||
| let b = "2"; // prompt("Segundo número?", 2); | ||||||||||
Member 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
Collaborator 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
Misma puerca pero revolcada... | ||||||||||
| alert(a + b); // 12 | ||||||||||
| ``` | ||||||||||
| What we should to is to convert strings to numbers before `+`. For example, using `Number()` or prepending them with `+`. | ||||||||||
| Lo que debemos hacer es convertir las cadenas de texto a números antes `+`. Por ejemplo, utilizando `Number()` o anteponiendo `+`. | ||||||||||
Member 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
hubiera aclarado binario + anteponiendo unario + o ante "+" | ||||||||||
| For example, right before `prompt`: | ||||||||||
| Por ejemplo, justo antes de `prompt`: | ||||||||||
| ```js run | ||||||||||
| let a = +prompt("First number?", 1); | ||||||||||
| let b = +prompt("Second number?", 2); | ||||||||||
| let a = +prompt("Primer número?", 1); | ||||||||||
Member 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
Collaborator 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
| ||||||||||
| let b = +prompt("Segundo número?", 2); | ||||||||||
Member 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
Collaborator 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
Same... | ||||||||||
| alert(a + b); // 3 | ||||||||||
| ``` | ||||||||||
| Or in the `alert`: | ||||||||||
| O en el `alert`: | ||||||||||
| ```js run | ||||||||||
| let a = prompt("First number?", 1); | ||||||||||
| let b = prompt("Second number?", 2); | ||||||||||
| let a = prompt("Primer número?", 1); | ||||||||||
Member 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
Collaborator 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
| ||||||||||
| let b = prompt("Segundo número?", 2); | ||||||||||
Member 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
Collaborator 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
Same... | ||||||||||
| alert(+a + +b); // 3 | ||||||||||
| ``` | ||||||||||
| Using both unary and binary `+` in the latest code. Looks funny, doesn't it? | ||||||||||
| Usar ambos unario y binario `+` en el último ejemplo, se ve raro no? | ||||||||||
Member 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
mejor armada creo , ¿se ve raro o no? puaj no. | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -2,17 +2,17 @@ importance: 5 | ||||||||||
| --- | ||||||||||
| # Fix the addition | ||||||||||
| # Corregir la adición | ||||||||||
| Here's a code that asks the user for two numbers and shows their sum. | ||||||||||
| Aquí hay un código que le pide al usuario dos números y muestra su suma. | ||||||||||
| It works incorrectly. The output in the example below is `12` (for default prompt values). | ||||||||||
| Funciona incorrectamente. El resultado en el ejemplo a continuación es `12` (para valores de captura predeterminados). | ||||||||||
Member 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
| ||||||||||
| Why? Fix it. The result should be `3`. | ||||||||||
| ¿Por qué? Arreglalo. El resultado debería ser `3`. | ||||||||||
Member 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
| ||||||||||
| ```js run | ||||||||||
| let a = prompt("First number?", 1); | ||||||||||
| let b = prompt("Second number?", 2); | ||||||||||
| let a = prompt("Primer número?", 1); | ||||||||||
Member 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
Collaborator 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
Otro!?!?!? | ||||||||||
| let b = prompt("Segundo número?", 2); | ||||||||||
Member 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
otro?? Collaborator 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
Y otro.. Member 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. ¿HAss VISTO? | ||||||||||
| alert(a + b); // 12 | ||||||||||
| ``` | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
Don makumi me convenció que ingresso es mas cool
estoy de acuerdo
aunque también te cambié el armado...