dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
77 lines
1.7 KiB
Markdown
77 lines
1.7 KiB
Markdown
---
|
|
id: 56533eb9ac21ba0edf2244b7
|
|
title: Concatenating Strings with Plus Operator
|
|
challengeType: 1
|
|
forumTopicId: 16802
|
|
dashedName: concatenating-strings-with-plus-operator
|
|
---
|
|
|
|
# --description--
|
|
|
|
In JavaScript, when the `+` operator is used with a `String` value, it is called the <dfn>concatenation</dfn> operator. You can build a new string out of other strings by <dfn>concatenating</dfn> them together.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
'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:
|
|
|
|
```js
|
|
const 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 single space character between the two strings.
|
|
|
|
```js
|
|
assert(/start\. This/.test(myStr));
|
|
```
|
|
|
|
`myStr` should have a value of the string `This is the start. This is the end.`
|
|
|
|
```js
|
|
assert(myStr === 'This is the start. This is the end.');
|
|
```
|
|
|
|
You should use the `+` operator to build `myStr`.
|
|
|
|
```js
|
|
assert(__helpers.removeJSComments(code).match(/(["']).*\1\s*\+\s*(["']).*\2/g));
|
|
```
|
|
|
|
`myStr` should be created using the `const` keyword.
|
|
|
|
```js
|
|
assert(/const\s+myStr/.test(__helpers.removeJSComments(code)));
|
|
```
|
|
|
|
You should assign the result to the `myStr` variable.
|
|
|
|
```js
|
|
assert(/myStr\s*=/.test(__helpers.removeJSComments(code)));
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
const myStr = ""; // Change this line
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
const myStr = "This is the start. " + "This is the end.";
|
|
```
|