2.1 KiB
2.1 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244b8 | Concatenating Strings with the Plus Equals Operator | 1 | Concatenando cadenas con el operador Plus Equals |
Description
+=
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 Cuidado con los espacios. La concatenación no agrega espacios entre las cadenas concatenadas, por lo que deberá agregarlas usted mismo.
Instructions
myStr
en varias líneas concatenando estas dos cadenas: "This is the first sentence. "
y "This is the second sentence."
utilizando el operador +=
. Utilice el operador +=
similar a como se muestra en el editor. Comience por asignar la primera cadena a myStr
, luego agregue la segunda cadena. Tests
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>");'
Challenge Seed
// Example
var ourStr = "I come first. ";
ourStr += "I come second.";
// Only change code below this line
var myStr;
After Test
console.info('after the test');
Solution
// solution required