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

1.7 KiB

id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244b9 Constructing Strings with Variables 1 Construyendo cuerdas con variables

Description

A veces necesitarás construir una cadena, al estilo de Mad Libs . Al utilizar el operador de concatenación ( + ), puede insertar una o más variables en una cadena que está creando.

Instructions

Establezca myName en una cadena igual a su nombre y compile myStr con myName entre las cadenas "My name is " y " and I am well!"

Tests

tests:
  - text: <code>myName</code> debe establecerse en una cadena de al menos 3 caracteres
    testString: 'assert(typeof myName !== "undefined" && myName.length > 2, "<code>myName</code> should be set to a string at least 3 characters long");'
  - text: Usa dos operadores <code>+</code> para construir <code>myStr</code> con <code>myName</code> dentro de él
    testString: 'assert(code.match(/[""]\s*\+\s*myName\s*\+\s*[""]/g).length > 0, "Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it");'

Challenge Seed

// Example
var ourName = "freeCodeCamp";
var ourStr = "Hello, our name is " + ourName + ", how are you?";

// Only change code below this line
var myName;
var myStr;

After Test

console.info('after the test');

Solution

// solution required