chore(i18n,curriculum): update translations
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
e139fbcf13
commit
c1fb339bbc
@ -13,7 +13,7 @@ La programación funcional consiste en crear y utilizar funciones no mutantes.
|
||||
El último desafío introdujo el método `concat` como una forma de combinar arreglos en uno nuevo sin mutar los arreglos originales. Compara `concat` con el método `push`. `push` añade un elemento al final del arreglo desde el que se llama, lo cual muta ese arreglo. Aquí hay un ejemplo:
|
||||
|
||||
```js
|
||||
var arr = [1, 2, 3];
|
||||
const arr = [1, 2, 3];
|
||||
arr.push([4, 5, 6]);
|
||||
```
|
||||
|
||||
@ -71,8 +71,9 @@ function nonMutatingPush(original, newItem) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
var first = [1, 2, 3];
|
||||
var second = [4, 5];
|
||||
|
||||
const first = [1, 2, 3];
|
||||
const second = [4, 5];
|
||||
nonMutatingPush(first, second);
|
||||
```
|
||||
|
||||
@ -82,7 +83,6 @@ nonMutatingPush(first, second);
|
||||
function nonMutatingPush(original, newItem) {
|
||||
return original.concat(newItem);
|
||||
}
|
||||
var first = [1, 2, 3];
|
||||
var second = [4, 5];
|
||||
nonMutatingPush(first, second);
|
||||
const first = [1, 2, 3];
|
||||
const second = [4, 5];
|
||||
```
|
||||
|
@ -77,7 +77,6 @@ function urlSlug(title) {
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
// Only change code below this line
|
||||
function urlSlug(title) {
|
||||
return title.trim().split(/\s+/).join("-").toLowerCase();
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ La función `incrementer` debe devolver un valor basado en el valor de la variab
|
||||
|
||||
```js
|
||||
// The global variable
|
||||
var fixedValue = 4;
|
||||
let fixedValue = 4;
|
||||
|
||||
function incrementer () {
|
||||
function incrementer() {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ function incrementer () {
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
var fixedValue = 4
|
||||
let fixedValue = 4
|
||||
|
||||
function incrementer() {
|
||||
return fixedValue + 1
|
||||
|
@ -13,8 +13,8 @@ El método `join` se utiliza para unir los elementos de un arreglo creando una c
|
||||
Aquí hay un ejemplo:
|
||||
|
||||
```js
|
||||
var arr = ["Hello", "World"];
|
||||
var str = arr.join(" ");
|
||||
const arr = ["Hello", "World"];
|
||||
const str = arr.join(" ");
|
||||
```
|
||||
|
||||
`str` tendrá una cadena con valor `Hello World`.
|
||||
@ -76,6 +76,7 @@ function sentensify(str) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
sentensify("May-the-force-be-with-you");
|
||||
```
|
||||
|
||||
@ -83,8 +84,6 @@ sentensify("May-the-force-be-with-you");
|
||||
|
||||
```js
|
||||
function sentensify(str) {
|
||||
// Only change code below this line
|
||||
return str.split(/\W/).join(' ');
|
||||
// Only change code above this line
|
||||
}
|
||||
```
|
||||
|
@ -60,8 +60,9 @@ function nonMutatingConcat(original, attach) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
var first = [1, 2, 3];
|
||||
var second = [4, 5];
|
||||
|
||||
const first = [1, 2, 3];
|
||||
const second = [4, 5];
|
||||
nonMutatingConcat(first, second);
|
||||
```
|
||||
|
||||
@ -69,11 +70,8 @@ nonMutatingConcat(first, second);
|
||||
|
||||
```js
|
||||
function nonMutatingConcat(original, attach) {
|
||||
// Only change code below this line
|
||||
return original.concat(attach);
|
||||
// Only change code above this line
|
||||
}
|
||||
var first = [1, 2, 3];
|
||||
var second = [4, 5];
|
||||
nonMutatingConcat(first, second);
|
||||
const first = [1, 2, 3];
|
||||
const second = [4, 5];
|
||||
```
|
||||
|
@ -38,17 +38,17 @@ assert(!code.match(/\.?[\s\S]*?map/g));
|
||||
|
||||
```js
|
||||
// The global variable
|
||||
var s = [23, 65, 98, 5];
|
||||
const s = [23, 65, 98, 5];
|
||||
|
||||
Array.prototype.myMap = function(callback) {
|
||||
var newArray = [];
|
||||
const newArray = [];
|
||||
// Only change code below this line
|
||||
|
||||
// Only change code above this line
|
||||
return newArray;
|
||||
};
|
||||
|
||||
var new_s = s.myMap(function(item) {
|
||||
const new_s = s.myMap(function(item) {
|
||||
return item * 2;
|
||||
});
|
||||
```
|
||||
@ -56,20 +56,17 @@ var new_s = s.myMap(function(item) {
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
// the global Array
|
||||
var s = [23, 65, 98, 5];
|
||||
const s = [23, 65, 98, 5];
|
||||
|
||||
Array.prototype.myMap = function(callback) {
|
||||
var newArray = [];
|
||||
// Only change code below this line
|
||||
for (var elem of this) {
|
||||
const newArray = [];
|
||||
for (const elem of this) {
|
||||
newArray.push(callback(elem));
|
||||
}
|
||||
// Only change code above this line
|
||||
return newArray;
|
||||
};
|
||||
|
||||
var new_s = s.myMap(function(item) {
|
||||
const new_s = s.myMap(function(item) {
|
||||
return item * 2;
|
||||
});
|
||||
```
|
||||
|
@ -34,16 +34,16 @@ assert(!code.match(/\.?[\s\S]*?filter/g));
|
||||
|
||||
```js
|
||||
// The global variable
|
||||
var s = [23, 65, 98, 5];
|
||||
const s = [23, 65, 98, 5];
|
||||
|
||||
Array.prototype.myFilter = function(callback) {
|
||||
// Only change code below this line
|
||||
var newArray = [];
|
||||
const newArray = [];
|
||||
// Only change code above this line
|
||||
return newArray;
|
||||
};
|
||||
|
||||
var new_s = s.myFilter(function(item) {
|
||||
const new_s = s.myFilter(function(item) {
|
||||
return item % 2 === 1;
|
||||
});
|
||||
```
|
||||
@ -51,20 +51,17 @@ var new_s = s.myFilter(function(item) {
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
// the global Array
|
||||
var s = [23, 65, 98, 5];
|
||||
const s = [23, 65, 98, 5];
|
||||
|
||||
Array.prototype.myFilter = function(callback) {
|
||||
var newArray = [];
|
||||
// Only change code below this line
|
||||
const newArray = [];
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (callback(this[i])) newArray.push(this[i]);
|
||||
}
|
||||
// Only change code above this line
|
||||
return newArray;
|
||||
};
|
||||
|
||||
var new_s = s.myFilter(function(item) {
|
||||
const new_s = s.myFilter(function(item) {
|
||||
return item % 2 === 1;
|
||||
});
|
||||
```
|
||||
|
@ -35,7 +35,7 @@ curried(1)(2)
|
||||
Esto es útil en tu programa si no puedes proporcionar todos los argumentos a una función al mismo tiempo. Puedes guardar la llamada a cada función dentro de una variable, la cual mantendrá la referencia de la función devuelta que toma el siguiente argumento cuando este disponible. Aquí hay un ejemplo utilizando la función currificada del ejemplo anterior:
|
||||
|
||||
```js
|
||||
var funcForY = curried(1);
|
||||
const funcForY = curried(1);
|
||||
console.log(funcForY(2)); // 3
|
||||
```
|
||||
|
||||
@ -45,7 +45,8 @@ Similarmente, <dfn>la aplicación de una función parcial</dfn> puede describirs
|
||||
function impartial(x, y, z) {
|
||||
return x + y + z;
|
||||
}
|
||||
var partialFn = impartial.bind(this, 1, 2);
|
||||
|
||||
const partialFn = impartial.bind(this, 1, 2);
|
||||
partialFn(10); // 13
|
||||
```
|
||||
|
||||
@ -90,6 +91,7 @@ function add(x) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
add(10)(20)(30);
|
||||
```
|
||||
|
||||
|
@ -53,10 +53,10 @@ assert(__newValue === 5);
|
||||
|
||||
```js
|
||||
// The global variable
|
||||
var fixedValue = 4;
|
||||
let fixedValue = 4;
|
||||
|
||||
// Only change code below this line
|
||||
function incrementer () {
|
||||
function incrementer() {
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
@ -66,15 +66,9 @@ function incrementer () {
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
// The global variable
|
||||
var fixedValue = 4;
|
||||
let fixedValue = 4;
|
||||
|
||||
// Only change code below this line
|
||||
function incrementer (fixedValue) {
|
||||
function incrementer(fixedValue) {
|
||||
return fixedValue + 1;
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ dashedName: remove-elements-from-an-array-using-slice-instead-of-splice
|
||||
Un patrón común al trabajar con arreglos es cuando deseas eliminar elementos y conservar el resto del arreglo. JavaScript ofrece el método `splice` para esto, que toma argumentos para el índice de dónde comenzar a eliminar elementos, luego la cantidad de elementos para eliminar. Si no se proporciona el segundo argumento, el valor predeterminado es eliminar elementos hasta el final. Sin embargo, el método `splice` muta el arreglo original en el que se llama. Por ejemplo:
|
||||
|
||||
```js
|
||||
var cities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
|
||||
const cities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
|
||||
cities.splice(3, 1);
|
||||
```
|
||||
|
||||
@ -69,7 +69,8 @@ function nonMutatingSplice(cities) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
var inputCities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
|
||||
|
||||
const inputCities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
|
||||
nonMutatingSplice(inputCities);
|
||||
```
|
||||
|
||||
@ -77,10 +78,7 @@ nonMutatingSplice(inputCities);
|
||||
|
||||
```js
|
||||
function nonMutatingSplice(cities) {
|
||||
// Only change code below this line
|
||||
return cities.slice(0,3);
|
||||
// Only change code above this line
|
||||
}
|
||||
var inputCities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
|
||||
nonMutatingSplice(inputCities);
|
||||
const inputCities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
|
||||
```
|
||||
|
@ -68,24 +68,23 @@ assert(JSON.stringify(nonMutatingSort([140000, 104, 99])) ===
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
var globalArray = [5, 6, 3, 2, 9];
|
||||
const globalArray = [5, 6, 3, 2, 9];
|
||||
|
||||
function nonMutatingSort(arr) {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
nonMutatingSort(globalArray);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
var globalArray = [5, 6, 3, 2, 9];
|
||||
const globalArray = [5, 6, 3, 2, 9];
|
||||
function nonMutatingSort(arr) {
|
||||
// Only change code below this line
|
||||
return [].concat(arr).sort((a,b) => a-b);
|
||||
// Only change code above this line
|
||||
}
|
||||
nonMutatingSort(globalArray);
|
||||
```
|
||||
|
@ -13,8 +13,8 @@ El método `slice` devuelve una copia de ciertos elementos de un arreglo. Puede
|
||||
Por ejemplo:
|
||||
|
||||
```js
|
||||
var arr = ["Cat", "Dog", "Tiger", "Zebra"];
|
||||
var newArray = arr.slice(1, 3);
|
||||
const arr = ["Cat", "Dog", "Tiger", "Zebra"];
|
||||
const newArray = arr.slice(1, 3);
|
||||
```
|
||||
|
||||
`newArray` tendría el valor de `["Dog", "Tiger"]`.
|
||||
@ -78,7 +78,8 @@ function sliceArray(anim, beginSlice, endSlice) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
var inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
|
||||
|
||||
const inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
|
||||
sliceArray(inputAnim, 1, 3);
|
||||
```
|
||||
|
||||
@ -86,10 +87,7 @@ sliceArray(inputAnim, 1, 3);
|
||||
|
||||
```js
|
||||
function sliceArray(anim, beginSlice, endSlice) {
|
||||
// Only change code below this line
|
||||
return anim.slice(beginSlice, endSlice)
|
||||
// Only change code above this line
|
||||
return anim.slice(beginSlice, endSlice);
|
||||
}
|
||||
var inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
|
||||
sliceArray(inputAnim, 1, 3);
|
||||
const inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
|
||||
```
|
||||
|
@ -18,6 +18,7 @@ function ascendingOrder(arr) {
|
||||
return a - b;
|
||||
});
|
||||
}
|
||||
|
||||
ascendingOrder([1, 5, 2, 3, 4]);
|
||||
```
|
||||
|
||||
@ -29,6 +30,7 @@ function reverseAlpha(arr) {
|
||||
return a === b ? 0 : a < b ? 1 : -1;
|
||||
});
|
||||
}
|
||||
|
||||
reverseAlpha(['l', 'h', 'z', 'b', 's']);
|
||||
```
|
||||
|
||||
@ -86,6 +88,7 @@ function alphabeticalOrder(arr) {
|
||||
return arr
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
|
||||
```
|
||||
|
||||
@ -93,9 +96,6 @@ alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
|
||||
|
||||
```js
|
||||
function alphabeticalOrder(arr) {
|
||||
// Only change code below this line
|
||||
return arr.sort();
|
||||
// Only change code above this line
|
||||
}
|
||||
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
|
||||
```
|
||||
|
@ -13,11 +13,11 @@ El método `split` divide una cadena en un arreglo de cadenas. Se necesita un ar
|
||||
Aquí hay dos ejemplos que dividen una cadena por espacios, luego otra por dígitos utilizando una expresión regular:
|
||||
|
||||
```js
|
||||
var str = "Hello World";
|
||||
var bySpace = str.split(" ");
|
||||
const str = "Hello World";
|
||||
const bySpace = str.split(" ");
|
||||
|
||||
var otherString = "How9are7you2today";
|
||||
var byDigits = otherString.split(/\d/);
|
||||
const otherString = "How9are7you2today";
|
||||
const byDigits = otherString.split(/\d/);
|
||||
```
|
||||
|
||||
`bySpace` tendrá el valor `["Hello", "World"]` y `byDigits` tendrá el valor `["How", "are", "you", "today"]`.
|
||||
@ -74,6 +74,7 @@ function splitify(str) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
splitify("Hello World,I-am code");
|
||||
```
|
||||
|
||||
@ -81,8 +82,6 @@ splitify("Hello World,I-am code");
|
||||
|
||||
```js
|
||||
function splitify(str) {
|
||||
// Only change code below this line
|
||||
return str.split(/\W/);
|
||||
// Only change code above this line
|
||||
}
|
||||
```
|
||||
|
@ -59,29 +59,29 @@ assert.deepEqual(finalTabs.tabs, [
|
||||
|
||||
```js
|
||||
// tabs is an array of titles of each site open within the window
|
||||
var Window = function(tabs) {
|
||||
const Window = function(tabs) {
|
||||
this.tabs = tabs; // We keep a record of the array inside the object
|
||||
};
|
||||
|
||||
// When you join two windows into one window
|
||||
Window.prototype.join = function (otherWindow) {
|
||||
Window.prototype.join = function(otherWindow) {
|
||||
this.tabs = this.tabs.concat(otherWindow.tabs);
|
||||
return this;
|
||||
};
|
||||
|
||||
// When you open a new tab at the end
|
||||
Window.prototype.tabOpen = function (tab) {
|
||||
Window.prototype.tabOpen = function(tab) {
|
||||
this.tabs.push('new tab'); // Let's open a new tab for now
|
||||
return this;
|
||||
};
|
||||
|
||||
// When you close a tab
|
||||
Window.prototype.tabClose = function (index) {
|
||||
Window.prototype.tabClose = function(index) {
|
||||
|
||||
// Only change code below this line
|
||||
|
||||
var tabsBeforeIndex = this.tabs.splice(0, index); // Get the tabs before the tab
|
||||
var tabsAfterIndex = this.tabs.splice(index + 1); // Get the tabs after the tab
|
||||
const tabsBeforeIndex = this.tabs.splice(0, index); // Get the tabs before the tab
|
||||
const tabsAfterIndex = this.tabs.splice(index + 1); // Get the tabs after the tab
|
||||
|
||||
this.tabs = tabsBeforeIndex.concat(tabsAfterIndex); // Join them together
|
||||
|
||||
@ -91,12 +91,12 @@ Window.prototype.tabClose = function (index) {
|
||||
};
|
||||
|
||||
// Let's create three browser windows
|
||||
var workWindow = new Window(['GMail', 'Inbox', 'Work mail', 'Docs', 'freeCodeCamp']); // Your mailbox, drive, and other work sites
|
||||
var socialWindow = new Window(['FB', 'Gitter', 'Reddit', 'Twitter', 'Medium']); // Social sites
|
||||
var videoWindow = new Window(['Netflix', 'YouTube', 'Vimeo', 'Vine']); // Entertainment sites
|
||||
const workWindow = new Window(['GMail', 'Inbox', 'Work mail', 'Docs', 'freeCodeCamp']); // Your mailbox, drive, and other work sites
|
||||
const socialWindow = new Window(['FB', 'Gitter', 'Reddit', 'Twitter', 'Medium']); // Social sites
|
||||
const videoWindow = new Window(['Netflix', 'YouTube', 'Vimeo', 'Vine']); // Entertainment sites
|
||||
|
||||
// Now perform the tab opening, closing, and other operations
|
||||
var finalTabs = socialWindow
|
||||
const finalTabs = socialWindow
|
||||
.tabOpen() // Open a new tab for cat memes
|
||||
.join(videoWindow.tabClose(2)) // Close third tab in video window, and join
|
||||
.join(workWindow.tabClose(1).tabOpen());
|
||||
@ -106,40 +106,34 @@ console.log(finalTabs.tabs);
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
// tabs is an array of titles of each site open within the window
|
||||
var Window = function(tabs) {
|
||||
this.tabs = tabs; // We keep a record of the array inside the object
|
||||
const Window = function(tabs) {
|
||||
this.tabs = tabs;
|
||||
};
|
||||
|
||||
// When you join two windows into one window
|
||||
Window.prototype.join = function (otherWindow) {
|
||||
Window.prototype.join = function(otherWindow) {
|
||||
this.tabs = this.tabs.concat(otherWindow.tabs);
|
||||
return this;
|
||||
};
|
||||
|
||||
// When you open a new tab at the end
|
||||
Window.prototype.tabOpen = function (tab) {
|
||||
this.tabs.push('new tab'); // Let's open a new tab for now
|
||||
Window.prototype.tabOpen = function(tab) {
|
||||
this.tabs.push('new tab');
|
||||
return this;
|
||||
};
|
||||
|
||||
// When you close a tab
|
||||
Window.prototype.tabClose = function (index) {
|
||||
var tabsBeforeIndex = this.tabs.slice(0, index); // Get the tabs before the tab
|
||||
var tabsAfterIndex = this.tabs.slice(index + 1); // Get the tabs after the tab
|
||||
Window.prototype.tabClose = function(index) {
|
||||
const tabsBeforeIndex = this.tabs.slice(0, index);
|
||||
const tabsAfterIndex = this.tabs.slice(index + 1);
|
||||
|
||||
this.tabs = tabsBeforeIndex.concat(tabsAfterIndex); // Join them together
|
||||
this.tabs = tabsBeforeIndex.concat(tabsAfterIndex);
|
||||
return this;
|
||||
};
|
||||
|
||||
// Let's create three browser windows
|
||||
var workWindow = new Window(['GMail', 'Inbox', 'Work mail', 'Docs', 'freeCodeCamp']); // Your mailbox, drive, and other work sites
|
||||
var socialWindow = new Window(['FB', 'Gitter', 'Reddit', 'Twitter', 'Medium']); // Social sites
|
||||
var videoWindow = new Window(['Netflix', 'YouTube', 'Vimeo', 'Vine']); // Entertainment sites
|
||||
const workWindow = new Window(['GMail', 'Inbox', 'Work mail', 'Docs', 'freeCodeCamp']);
|
||||
const socialWindow = new Window(['FB', 'Gitter', 'Reddit', 'Twitter', 'Medium']);
|
||||
const videoWindow = new Window(['Netflix', 'YouTube', 'Vimeo', 'Vine']);
|
||||
|
||||
// Now perform the tab opening, closing, and other operations
|
||||
var finalTabs = socialWindow
|
||||
.tabOpen() // Open a new tab for cat memes
|
||||
.join(videoWindow.tabClose(2)) // Close third tab in video window, and join
|
||||
const finalTabs = socialWindow
|
||||
.tabOpen()
|
||||
.join(videoWindow.tabClose(2))
|
||||
.join(workWindow.tabClose(1).tabOpen());
|
||||
```
|
||||
|
@ -13,7 +13,8 @@ El método `every` funciona con arreglos para comprobar si *every element* pasa
|
||||
Por ejemplo, el siguiente código comprobaría si cada elemento en el arreglo `numbers` es menor a 10:
|
||||
|
||||
```js
|
||||
var numbers = [1, 5, 8, 0, 10, 11];
|
||||
const numbers = [1, 5, 8, 0, 10, 11];
|
||||
|
||||
numbers.every(function(currentValue) {
|
||||
return currentValue < 10;
|
||||
});
|
||||
@ -62,6 +63,7 @@ function checkPositive(arr) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
checkPositive([1, 2, 3, -4, 5]);
|
||||
```
|
||||
|
||||
@ -69,9 +71,6 @@ checkPositive([1, 2, 3, -4, 5]);
|
||||
|
||||
```js
|
||||
function checkPositive(arr) {
|
||||
// Only change code below this line
|
||||
return arr.every(num => num > 0);
|
||||
// Only change code above this line
|
||||
}
|
||||
checkPositive([1, 2, 3, -4, 5]);
|
||||
```
|
||||
|
@ -93,7 +93,7 @@ assert(getRating(watchList.filter((_, i) => i < 1 || i > 2)) === 8.55);
|
||||
|
||||
```js
|
||||
// The global variable
|
||||
var watchList = [
|
||||
const watchList = [
|
||||
{
|
||||
"Title": "Inception",
|
||||
"Year": "2010",
|
||||
@ -206,22 +206,22 @@ var watchList = [
|
||||
}
|
||||
];
|
||||
|
||||
function getRating(watchList){
|
||||
function getRating(watchList) {
|
||||
// Only change code below this line
|
||||
var averageRating;
|
||||
let averageRating;
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return averageRating;
|
||||
}
|
||||
|
||||
console.log(getRating(watchList));
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
// The global variable
|
||||
var watchList = [
|
||||
const watchList = [
|
||||
{
|
||||
"Title": "Inception",
|
||||
"Year": "2010",
|
||||
@ -334,8 +334,8 @@ var watchList = [
|
||||
}
|
||||
];
|
||||
|
||||
function getRating(watchList){
|
||||
var averageRating;
|
||||
function getRating(watchList) {
|
||||
let averageRating;
|
||||
const rating = watchList
|
||||
.filter(obj => obj.Director === "Christopher Nolan")
|
||||
.map(obj => Number(obj.imdbRating));
|
||||
|
@ -13,7 +13,8 @@ El método `some` funciona con arreglos para comprobar si *algún* elemento pasa
|
||||
Por ejemplo, el siguiente código comprobará si algún elemento en el arreglo `numbers` es menor que 10:
|
||||
|
||||
```js
|
||||
var numbers = [10, 50, 8, 220, 110, 11];
|
||||
const numbers = [10, 50, 8, 220, 110, 11];
|
||||
|
||||
numbers.some(function(currentValue) {
|
||||
return currentValue < 10;
|
||||
});
|
||||
@ -62,6 +63,7 @@ function checkPositive(arr) {
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
checkPositive([1, 2, 3, -4, 5]);
|
||||
```
|
||||
|
||||
@ -69,9 +71,6 @@ checkPositive([1, 2, 3, -4, 5]);
|
||||
|
||||
```js
|
||||
function checkPositive(arr) {
|
||||
// Only change code below this line
|
||||
return arr.some(elem => elem > 0);
|
||||
// Only change code above this line
|
||||
}
|
||||
checkPositive([1, 2, 3, -4, 5]);
|
||||
```
|
||||
|
Reference in New Issue
Block a user