Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

2.3 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
56bbb991ad1ed5201cd392cf Write Reusable JavaScript with Functions 1 用函数编写可重用的JavaScript

Description

在JavaScript中我们可以将代码划分为称为函数的可重用部分。这是一个函数的例子:
function functionName{
console.log“Hello World”;
}
您可以使用其名称后跟括号来调用或调用此函数,如下所示: functionName();每次调用该函数时,它都会在开发控制台上打印出"Hello World"消息。每次调用函数时,都会执行大括号之间的所有代码。

Instructions

  1. 创建一个名为reusableFunction的函数,它将"Hi World"打印到开发控制台。
  2. 调用该功能。

Tests

tests:
  - text: <code>reusableFunction</code>应该是一个函数
    testString: assert(typeof reusableFunction === 'function');
  - text: <code>reusableFunction</code>应该将“Hi World”输出到开发控制台
    testString: assert(hiWorldWasLogged);
  - text: 定义后调用<code>reusableFunction</code>
    testString: assert(/^\s*reusableFunction\(\)\s*/m.test(code));

Challenge Seed

// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line

Before Test

var logOutput = "";
var originalConsole = console
function capture() {
    var nativeLog = console.log;
    console.log = function (message) {
        if(message && message.trim) logOutput = message.trim();
        if(nativeLog.apply) {
          nativeLog.apply(originalConsole, arguments);
        } else {
          var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
          nativeLog(nativeMsg);
        }
    };
}

function uncapture() {
  console.log = originalConsole.log;
}

capture();

After Test

console.info('after the test');

Solution

// solution required