Files
freeCodeCamp/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md
Patrick Lehmann 5371af7767 fix(learn): removed space from first sentence and added instruction to basic javascript challenges (#43198)
* sheesh

* added markdown formatting to challenge

* added formatting to keep space in concatenating strings with the plus equals operator

* Delete husky.sh

* added back in italian dictionary

* removed code formatting

* updating text formatting for challenges, removed space and added instruction

Co-authored-by: Pat Lehmann <patrick.lehmann@homes.com>
2021-08-24 10:26:45 -07:00

1.7 KiB

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

--description--

In JavaScript, when the + operator is used with a String value, it is called the concatenation operator. You can build a new string out of other strings by concatenating them together.

Example

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

Note: Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you'll need to add them yourself.

Example:

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

The string I come first. I come second. would be displayed in the console.

--instructions--

Build myStr from the strings This is the start. and This is the end. using the + operator. Be sure to include a space between the two strings.

--hints--

myStr should have a value of the string This is the start. This is the end.

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

You should use the + operator to build myStr.

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

myStr should be created using the var keyword.

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

You should assign the result to the myStr variable.

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.";