Files
freeCodeCamp/curriculum/challenges/ukrainian/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md
2022-12-16 19:03:44 +02:00

2.0 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244ed Додавання змінних до рядків 1 https://scrimba.com/c/cbQmZfa 16656 appending-variables-to-strings

--description--

Ми можемо створити рядок з декількох рядкових літералів, і так само ми можемо додати змінні до рядка, використовуючи оператор додавання з присвоєнням (+=).

Приклад:

const anAdjective = "awesome!";
let ourStr = "freeCodeCamp is ";
ourStr += anAdjective;

ourStr матиме значення freeCodeCamp is awesome!.

--instructions--

Встановіть someAdjective на рядок з принаймні 3 символів та додайте його до myStr, використовуючи оператор +=.

--hints--

someAdjective повинен бути встановлений як рядок з принаймні 3 символів.

assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);

Ви повинні додати someAdjective до myStr, використовуючи оператор +=.

assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);

--seed--

--after-user-code--

(function(){
  var output = [];
  if(typeof someAdjective === 'string') {
    output.push('someAdjective = "' + someAdjective + '"');
  } else {
    output.push('someAdjective is not a string');
  }
  if(typeof myStr === 'string') {
    output.push('myStr = "' + myStr + '"');
  } else {
    output.push('myStr is not a string');
  }
  return output.join('\n');
})();

--seed-contents--

// Change code below this line
const someAdjective = "";
let myStr = "Learning to code is ";

--solutions--

const someAdjective = "neat";
let myStr = "Learning to code is ";
myStr += someAdjective;