-
Notifications
You must be signed in to change notification settings - Fork 230
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
Changes from all commits
5b36995
7d34563
a11a915
500d8e5
b14e252
ef70003
0b01e8b
3fb8d40
5a008f3
01716b7
470f5f8
4104623
fa1f7d2
b83d4b1
ec1088a
File filter
Filter by extension
Conversations
Jump to
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); | ||||||||||
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. 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 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 ( 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); | ||||||||||
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
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 `+`. | ||||||||||
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); | ||||||||||
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
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); | ||||||||||
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
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); | ||||||||||
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
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); | ||||||||||
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
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? | ||||||||||
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). | ||||||||||
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`. | ||||||||||
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); | ||||||||||
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
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); | ||||||||||
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?? 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.. 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 | ||||||||||
``` |
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...