Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Objects#321

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

Merged
joaquinelio merged 34 commits intojavascript-tutorial:masterfrommaksumi:objetos
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
34 commits
Select commitHold shift + click to select a range
0189e27
Merge pull request #1 from javascript-tutorial/master
Jul 17, 2020
e96e72c
Merge pull request #2 from javascript-tutorial/master
Jul 18, 2020
96d99aa
Update
Jul 23, 2020
f152057
Update
Jul 23, 2020
42f7cc6
Update
Jul 24, 2020
a17a435
Update
Jul 24, 2020
f17b890
Update
Jul 24, 2020
0db6fe7
Update
Jul 24, 2020
c3aee22
Update
Jul 25, 2020
22a88dc
Update
Jul 25, 2020
5228b7e
Update 1-js/04-object-basics/01-object/2-hello-object/task.md
Jul 25, 2020
41da662
Update task.md
Jul 25, 2020
84181ea
Update task.md
Jul 25, 2020
6fa85e8
Update solution.md
Jul 25, 2020
d5be7a6
Update 1-js/04-object-basics/01-object/8-multiply-numeric/_js.view/so…
Jul 25, 2020
a896cac
Update article.md
Jul 25, 2020
c69573f
Update article.md
Jul 25, 2020
2337f50
Update article.md
Jul 25, 2020
98ed40e
Update 1-js/04-object-basics/01-object/article.md
Jul 25, 2020
127a18f
Update 1-js/04-object-basics/01-object/article.md
Jul 25, 2020
216253d
Update 1-js/04-object-basics/01-object/article.md
Jul 25, 2020
ecb9dc2
Update article.md
Jul 25, 2020
89c905b
Update 1-js/04-object-basics/01-object/article.md
Jul 25, 2020
3965ce2
Update 1-js/04-object-basics/01-object/article.md
Jul 25, 2020
bbe7591
Update article.md
Jul 25, 2020
87b5292
Update article.md
Jul 26, 2020
3070aa6
Update
Jul 26, 2020
59c64ae
Update 1-js/04-object-basics/01-object/article.md
Jul 27, 2020
5ab2bda
Update 1-js/04-object-basics/01-object/article.md
Jul 27, 2020
6ee7129
Update 1-js/04-object-basics/01-object/article.md
Jul 27, 2020
07f7321
Update 1-js/04-object-basics/01-object/article.md
Jul 27, 2020
2609768
Update 1-js/04-object-basics/01-object/article.md
Jul 27, 2020
31ea37c
Update 1-js/04-object-basics/01-object/article.md
Jul 27, 2020
0bbfc4a
Apply suggestions from code review
Jul 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions1-js/04-object-basics/01-object/2-hello-object/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,13 +2,12 @@ importance: 5

---

#Hello, object
#Hola, objeto

Write the code, one line for each action:

1. Create an empty object `user`.
2. Add the property `name` with the value `John`.
3. Add the property `surname` with the value `Smith`.
4. Change the value of the `name` to `Pete`.
5. Remove the property `name` from the object.
Escribe el código, una línea para cada acción:

1. Crea un objeto `user` vacío.
2. Agrega la propiedad `name` con el valor `John`.
3. Agrega la propiedad `surname` con el valor `Smith`.
4. Cambia el valor de `name` a `Pete`.
5. Remueve la propiedad `name` del objeto.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
function isEmpty(obj) {
for (let key in obj) {
//if the loop has started, there is a property
// Si el bucle ha comenzado quiere decir que sí hay al menos una propiedad
return false;
}
return true;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
describe("isEmpty", function() {
it("returns truefor an empty object", function() {
it("retorna truepara un objeto vacío", function() {
assert.isTrue(isEmpty({}));
});

it("returns falseif a property exists", function() {
it("retorna falsesi existe una propiedad", function() {
assert.isFalse(isEmpty({
anything: false
}));
Expand Down
2 changes: 1 addition & 1 deletion1-js/04-object-basics/01-object/3-is-empty/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
Just loop over the object and `return false` immediately if there's at least one property.
Solo crea un bucle sobre el objeto y, si hay al menos una propiedad, devuelve `false` inmediatamente.
8 changes: 4 additions & 4 deletions1-js/04-object-basics/01-object/3-is-empty/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,18 +2,18 @@ importance: 5

---

#Check for emptiness
#Verificar los vacíos

Write the function `isEmpty(obj)`which returns`true`if the object hasnoproperties,`false` otherwise.
Escribe la función `isEmpty(obj)`que devuelva el valor`true`si el objetonotiene propiedades, en caso contrario`false`.

Should work like that:
Debería funcionar así:

```js
let schedule = {};

alert( isEmpty(schedule) ); // true

schedule["8:30"] = "get up";
schedule["8:30"] = "Hora de levantarse";

alert( isEmpty(schedule) ); // false
```
Expand Down
8 changes: 4 additions & 4 deletions1-js/04-object-basics/01-object/5-sum-object/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@ importance: 5

---

#Sum object properties
#Suma de propiedades de un objeto

We have an object storing salaries of our team:
Tenemos un objeto que almacena los salarios de nuestro equipo:

```js
let salaries = {
Expand All@@ -14,6 +14,6 @@ let salaries = {
}
```

Write the code to sum all salaries and store in thevariable `sum`.Should be `390` in the example above.
Escribe el código para sumar todos los salarios y almacenarl el resultado en lavariable `sum`.En el ejemplo de arriba nos debería dar `390`.

If `salaries`is empty, then the result must be `0`.
Si `salaries`está vacio entonces el resultado será `0`.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
let menu = {
width: 200,
height: 300,
title: "My menu"
title: "Mi menú"
};


function multiplyNumeric(obj) {

/*your code */
/*tu código */

}

multiplyNumeric(menu);

alert( "menu width=" + menu.width + " height=" + menu.height + " title=" + menu.title );

alert( "ancho del menú=" + menu.width + " alto=" + menu.height + " título=" + menu.title );
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
describe("multiplyNumeric", function() {
it("multiplies all numeric properties by 2", function() {
it("multiplicar todas las propiedades numéricas por 2", function() {
let menu = {
width: 200,
height: 300,
title: "My menu"
title: "Mi menú"
};
let result = multiplyNumeric(menu);
assert.equal(menu.width, 400);
assert.equal(menu.height, 600);
assert.equal(menu.title, "My menu");
assert.equal(menu.title, "Mi menú");
});

it("returns nothing", function() {
it("No devuelve nada", function() {
assert.isUndefined( multiplyNumeric({}) );
});

Expand Down
18 changes: 9 additions & 9 deletions1-js/04-object-basics/01-object/8-multiply-numeric/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,32 +2,32 @@ importance: 3

---

#Multiply numeric properties by 2
#Multiplicar propiedades numéricas por 2

Create a function `multiplyNumeric(obj)`that multiplies all numeric properties of`obj`by `2`.
Crea una función `multiplyNumeric(obj)`que multiplique todas las propiedades numéricas de`obj`por `2`.

For instance:
Por ejemplo:

```js
//before the call
//Antes de la llamada
let menu = {
width: 200,
height: 300,
title: "My menu"
title: "Mi menú"
};

multiplyNumeric(menu);

//after the call
//Después de la llamada
menu = {
width: 400,
height: 600,
title: "My menu"
title: "Mi menú"
};
```

Please note that`multiplyNumeric`does not need to return anything. It should modify the object in-place.
Nota que`multiplyNumeric`no necesita devolver nada. Debe modificar el objeto en su lugar.

P.S. Use `typeof`to check for a number here.
P.D. Usa `typeof`para verificar si hay un número aquí.


Loading

[8]ページ先頭

©2009-2025 Movatter.jp