+=
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 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. myStr
debe tener un valor de This is the first sentence. This is the second sentence.
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "myStr
should have a value of This is the first sentence. This is the second sentence.
");'
- text: Usa el operador +=
para construir myStr
testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the +=
operator to build myStr
");'
```