freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-an.../basic-javascript/nesting-for-loops.spanish.md

63 lines
2.2 KiB
Markdown
Raw Normal View History

2018-10-08 17:34:43 +00:00
---
id: 56533eb9ac21ba0edf2244e1
title: Nesting For Loops
challengeType: 1
2018-10-10 20:20:40 +00:00
videoUrl: ''
localeTitle: Anidando para bucles
2018-10-08 17:34:43 +00:00
---
## Description
2018-10-10 20:20:40 +00:00
<section id="description"> Si tiene una matriz multidimensional, puede usar la misma lógica que el punto de ruta anterior para recorrer tanto la matriz como cualquier subarreglo. Aquí hay un ejemplo: <blockquote> var arr = [ <br> [1,2], [3,4], [5,6] <br> ]; <br> para (var i = 0; i &lt;arr.length; i ++) { <br> para (var j = 0; j &lt;arr [i] .length; j ++) { <br> console.log (arr [i] [j]); <br> } <br> } </blockquote> Esto genera cada subelemento en <code>arr</code> uno a la vez. Tenga en cuenta que para el bucle interno, estamos comprobando la <code>.length</code> de <code>arr[i]</code> , ya que <code>arr[i]</code> es en sí misma una matriz. </section>
2018-10-08 17:34:43 +00:00
## Instructions
2018-10-10 20:20:40 +00:00
<section id="instructions"> Modifique la función <code>multiplyAll</code> para que multiplique la variable del <code>product</code> por cada número en los subarreglos de <code>arr</code> </section>
2018-10-08 17:34:43 +00:00
## Tests
<section id='tests'>
```yml
tests:
2018-10-10 20:20:40 +00:00
- text: '<code>multiplyAll([[1],[2],[3]])</code> debe devolver <code>6</code>'
2018-10-08 17:34:43 +00:00
testString: 'assert(multiplyAll([[1],[2],[3]]) === 6, "<code>multiplyAll([[1],[2],[3]])</code> should return <code>6</code>");'
2018-10-10 20:20:40 +00:00
- text: '<code>multiplyAll([[1,2],[3,4],[5,6,7]])</code> debe devolver <code>5040</code>'
2018-10-08 17:34:43 +00:00
testString: 'assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040, "<code>multiplyAll([[1,2],[3,4],[5,6,7]])</code> should return <code>5040</code>");'
2018-10-10 20:20:40 +00:00
- text: '<code>multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])</code> debe devolver <code>54</code>'
2018-10-08 17:34:43 +00:00
testString: 'assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54, "<code>multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])</code> should return <code>54</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
// Only change code above this line
return product;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
```
</div>
</section>
## Solution
<section id='solution'>
```js
2018-10-10 20:20:40 +00:00
// solution required
2018-10-08 17:34:43 +00:00
```
</section>