Files
freeCodeCamp/curriculum/challenges/espanol/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md
camperbot 529d72b242 chore(i18n,learn): processed translations (#41424)
* chore(i8n,learn): processed translations

* Update curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/use-the-u-tag-to-underline-text.md

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
2021-03-09 08:51:59 -07:00

1.8 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244b8 Concatena cadenas con el operador "más igual" 1 https://scrimba.com/c/cbQmmC4 16803 concatenating-strings-with-the-plus-equals-operator

--description--

También podemos utilizar el operador += para concatenar una cadena al final de una variable de cadena existente. Esto puede ser muy útil para romper una cadena larga en varias líneas.

Nota: Ten cuidado con los espacios. La concatenación no añade espacios entre las cadenas concatenadas, así que tendrás que añadirlos por tu cuenta.

Ejemplo:

var ourStr = "I come first. ";
ourStr += "I come second.";

ourStr ahora tiene un valor de la cadena I come first. I come second..

--instructions--

Construye myStr en varias líneas concatenando estas dos cadenas: This is the first sentence. y This is the second sentence. usando el operador +=. Utiliza el operador += de forma similar a como se muestra en el editor. Comienza asignando la primera cadena a myStr, luego añade la segunda cadena.

--hints--

myStr debe tener una cadena con valor This is the first sentence. This is the second sentence.

assert(myStr === 'This is the first sentence. This is the second sentence.');

Debes usar el operador += para construir myStr.

assert(code.match(/myStr\s*\+=\s*(["']).*\1/g));

--seed--

--after-user-code--

(function(){
  if(typeof myStr === 'string') {
    return 'myStr = "' + myStr + '"';
  } else {
    return 'myStr is not a string';
  }
})();

--seed-contents--

// Only change code below this line

var myStr;

--solutions--

var myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";