- Notifications
You must be signed in to change notification settings - Fork230
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 ourterms of service andprivacy 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 fromall commits
5b36995
7d34563
a11a915
500d8e5
b14e252
ef70003
0b01e8b
3fb8d40
5a008f3
01716b7
470f5f8
4104623
fa1f7d2
b83d4b1
ec1088a
File 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 @@ | ||
La respuesta es: | ||
- `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 @@ | ||||||||||
La razón es que la captura devuelve la entrada del usuario como una cadena. | ||||||||||
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
Don makumi me convenció que ingresso es mas cool | ||||||||||
Entonces lasvariablestienen valores `"1"`y `"2"`respectivamente. | ||||||||||
```js run | ||||||||||
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 | ||||||||||
``` | ||||||||||
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 "+" | ||||||||||
Por ejemplo, justo antes de `prompt`: | ||||||||||
```js run | ||||||||||
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 | ||||||||||
``` | ||||||||||
O en el `alert`: | ||||||||||
```js run | ||||||||||
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 | ||||||||||
``` | ||||||||||
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 | ||||||||||
--- | ||||||||||
#Corregir la adición | ||||||||||
Aquí hay un código que le pide al usuario dos números y muestra su suma. | ||||||||||
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
| ||||||||||
¿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("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 | ||||||||||
``` |
Uh oh!
There was an error while loading.Please reload this page.