4.5 KiB
4.5 KiB
id, title, challengeType, videoUrl, forumTopicId, localeTitle
id | title | challengeType | videoUrl | forumTopicId | localeTitle |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244b6 | Escape Sequences in Strings | 1 | https://scrimba.com/c/cvmqRh6 | 17567 | Последовательности выхода в строках |
Description
Код | Вывод |
---|---|
\' | одиночная цитата |
\" | двойная цитата |
\\ | обратный слэш |
\n | новая линия |
\r | возврат каретки |
\t | табуляция |
\b | возврат на одну позицию |
\f | форма подачи |
Instructions
myStr
используя escape-последовательности. Первая линияДля правильной вставки специальных символов вам необходимо использовать escape-последовательности. Вам также нужно будет следить за интервалом, как он выглядит выше, без пробелов между escape-последовательностями или словами. Вот текст с выведенными escape-последовательностями.
\Вторая линия
ThirdLine
FirstLineлинииnewline
tab
backslash
второй
newline
ThirdLine
Tests
tests:
- text: <code>myStr</code> should not contain any spaces
testString: assert(!/ /.test(myStr));
- text: <code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)
testString: assert(/FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr));
- text: <code>FirstLine</code> should be followed by the newline character <code>\n</code>
testString: assert(/FirstLine\n/.test(myStr));
- text: <code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character
testString: assert(/\n\t/.test(myStr));
- text: <code>SecondLine</code> should be preceded by the backslash character <code>\</code>
testString: assert(/\\SecondLine/.test(myStr));
- text: There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>
testString: assert(/SecondLine\nThirdLine/.test(myStr));
- text: <code>myStr</code> should only contain characters shown in the instructions
testString: assert(myStr === 'FirstLine\n\t\\SecondLine\nThirdLine');
Challenge Seed
var myStr; // Change this line
After Tests
(function(){
if (myStr !== undefined){
console.log('myStr:\n' + myStr);}})();
Solution
var myStr = "FirstLine\n\t\\SecondLine\nThirdLine";