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

1.8 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244b9 Constructing Strings with Variables 1 Construindo Strings com Variáveis

Description

Às vezes você precisará construir uma string, estilo Mad Libs . Usando o operador de concatenação ( + ), você pode inserir uma ou mais variáveis em uma string que está construindo.

Instructions

Definir myName para uma string igual ao seu nome e construir myStr com myName entre as seqüências de caracteres "My name is " e " and I am well!"

Tests

tests:
  - text: <code>myName</code> deve ser definido para uma string com pelo 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: Use dois <code>+</code> operadores para construir <code>myStr</code> com <code>myName</code> dentro dele
    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