Files
freeCodeCamp/curriculum/challenges/portuguese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md
Nicholas Carrigan (he/him) c4fd49e5b7 chore: manual translations (#42811)
2021-07-10 09:53:54 +05:30

1.7 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244b7 Concatenando Strings com Operador Mais 1 https://scrimba.com/c/cNpM8AN 16802 concatenating-strings-with-plus-operator

--description--

Em JavaScript, quando o operador + é usado com um valor de String, ele é chamado de operador de concatenação. Você pode construir uma nova string a partir de outras strings ao concatenar elas juntos.

Exemplo

'My name is Alan,' + ' I concatenate.'

Nota: Cuidado com os espaços. A concatenação não adiciona espaços entre strings concatenadas, então você mesmo precisará adicioná-las.

Exemplo:

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

A string I come first. I come second. seria exibida no console.

--instructions--

Construa myStr a partir das strings This is the start. e This is the end. usando o operador +.

--hints--

myStr deve ter o valor da string This is the start. This is the end.

assert(myStr === 'This is the start. This is the end.');

Você deve usar o operador + para construir myStr.

assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));

myStr deve ser criado usando a palavra-chave var.

assert(/var\s+myStr/.test(code));

Você deve atribuir o resultado à variável myStr.

assert(/myStr\s*=/.test(code));

--seed--

--after-user-code--

(function(){
  if(typeof myStr === 'string') {
    return 'myStr = "' + myStr + '"';
  } else {
    return 'myStr is not a string';
  }
})();

--seed-contents--

var myStr; // Change this line

--solutions--

var myStr = "This is the start. " + "This is the end.";