Randell Dawson 05f73ca409 fix(curriculum): Convert blockquote elements to triple backtick syntax for JavaScript Algorithms and Data Structures (#35992)
* fix: convert js algorithms and data structures

* fix: revert some blocks back to blockquote

* fix: reverted comparison code block to blockquotes

* fix: change js to json

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: convert various section to triple backticks

* fix: Make the formatting consistent for comparisons
2019-05-17 08:20:30 -05:00

2.3 KiB

id, title, challengeType, videoUrl
id title challengeType videoUrl
56533eb9ac21ba0edf2244b7 Concatenating Strings with Plus Operator 1 https://scrimba.com/c/cNpM8AN

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.

Instructions

Build myStr from the strings "This is the start. " and "This is the end." using the + operator.

Tests

tests:
  - text: <code>myStr</code> should have a value of <code>This is the start. This is the end.</code>
    testString: assert(myStr === "This is the start. This is the end.", '<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>');
  - text: Use the <code>+</code> operator to build <code>myStr</code>
    testString: assert(code.match(/(["']).*(["'])\s*\+\s*(["']).*(["'])/g).length > 1, 'Use the <code>+</code> operator to build <code>myStr</code>');
  - text: <code>myStr</code> should be created using the <code>var</code> keyword.
    testString: assert(/var\s+myStr/.test(code), '<code>myStr</code> should be created using the <code>var</code> keyword.');
  - text: Make sure to assign the result to the <code>myStr</code> variable.
    testString: assert(/myStr\s*=/.test(code), 'Make sure to assign the result to the <code>myStr</code> variable.');

Challenge Seed

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

// Only change code below this line

var myStr;


After Test

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

Solution

var ourStr = "I come first. " + "I come second.";
var myStr = "This is the start. " + "This is the end.";