freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-an.../basic-javascript/concatenating-strings-with-...

66 lines
2.1 KiB
Markdown
Raw Normal View History

2018-10-08 17:34:43 +00:00
---
id: 56533eb9ac21ba0edf2244b8
title: Concatenating Strings with the Plus Equals Operator
challengeType: 1
2018-10-10 20:20:40 +00:00
videoUrl: ''
localeTitle: Concatenando cadenas con el operador Plus Equals
2018-10-08 17:34:43 +00:00
---
## Description
2018-10-10 20:20:40 +00:00
<section id="description"> También podemos usar el operador <code>+=</code> para <dfn>concatenar</dfn> una cadena al final de una variable de cadena existente. Esto puede ser muy útil para romper una cadena larga en varias líneas. <strong>Nota</strong> <br> Cuidado con los espacios. La concatenación no agrega espacios entre las cadenas concatenadas, por lo que deberá agregarlas usted mismo. </section>
2018-10-08 17:34:43 +00:00
## Instructions
2018-10-10 20:20:40 +00:00
<section id="instructions"> Construya <code>myStr</code> en varias líneas concatenando estas dos cadenas: <code>&quot;This is the first sentence. &quot;</code> y <code>&quot;This is the second sentence.&quot;</code> utilizando el operador <code>+=</code> . Utilice el operador <code>+=</code> similar a como se muestra en el editor. Comience por asignar la primera cadena a <code>myStr</code> , luego agregue la segunda cadena. </section>
2018-10-08 17:34:43 +00:00
## Tests
<section id='tests'>
```yml
tests:
- text: <code>myStr</code> debe tener un valor de <code>This is the first sentence. This is the second sentence.</code>
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>");'
- text: Usa el operador <code>+=</code> para construir <code>myStr</code>
testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the <code>+=</code> operator to build <code>myStr</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourStr = "I come first. ";
ourStr += "I come second.";
// Only change code below this line
var myStr;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</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>