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

2.3 KiB

id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244b7 Concatenating Strings with Plus Operator 1 Concatenando cuerdas con el operador Plus

Description

En JavaScript, cuando el operador + se usa con un valor de String , se llama operador de concatenación . Puede construir una nueva cadena a partir de otras cadenas concatenándolas juntas. Ejemplo
'Mi nombre es Alan,' + 'Concatené'.
Nota
Cuidado con los espacios. La concatenación no agrega espacios entre las cadenas concatenadas, por lo que deberá agregarlas usted mismo.

Instructions

Construye myStr partir de las cadenas "This is the start. " y "This is the end." utilizando el operador + .

Tests

tests:
  - text: <code>myStr</code> debe tener un valor de <code>This is the start. This is the end.</code>
    testString: 'assert(myStr === "This is the start. This is the end.", "<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>");'
  - text: Usa el operador <code>+</code> para construir <code>myStr</code>
    testString: 'assert(code.match(/([""]).*([""])\s*\+\s*([""]).*([""])/g).length > 1, "Use the <code>+</code> operator to build <code>myStr</code>");'
  - text: <code>myStr</code> debe crearse usando la palabra clave <code>var</code> .
    testString: 'assert(/var\s+myStr/.test(code), "<code>myStr</code> should be created using the <code>var</code> keyword.");'
  - text: Asegúrese de asignar el resultado a la variable <code>myStr</code> .
    testString: 'assert(/myStr\s*=/.test(code), "Make sure to assign the result to the <code>myStr</code> variable.");'

Challenge Seed

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

// Only change code below this line

var myStr;

After Test

console.info('after the test');

Solution

// solution required