1.8 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244b7 | Concatenar strings com o 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 criar uma nova string a partir de outras strings ao concatenar elas juntos.
Exemplo
'My name is Alan,' + ' I concatenate.'
Observação: cuidado com os espaços. A concatenação não adiciona espaços entre strings concatenadas, então você mesmo precisará adicioná-las.
Exemplo:
const ourStr = "I come first. " + "I come second.";
A string I come first. I come second.
seria exibida no console.
--instructions--
Crie myStr
a partir das strings This is the start.
e This is the end.
usando o operador +
. Não se esqueça de incluir um espaço entre as duas strings.
--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 criar myStr
.
assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
myStr
deve ser criada usando a palavra-chave const
.
assert(/const\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--
const myStr = ""; // Change this line
--solutions--
const myStr = "This is the start. " + "This is the end.";