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

1.8 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
567af2437cbaa8c51670a16c Testing Objects for Properties 1 测试属性的对象

Description

有时检查给定对象的属性是否存在是有用的。我们可以使用对象的.hasOwnProperty(propname)方法来确定该对象是否具有给定的属性名称。 .hasOwnProperty()如果找到属性则返回truefalse
var myObj = {
顶部:“帽子”,
底部:“裤子”
};
myObj.hasOwnProperty “顶部”); //真的
myObj.hasOwnProperty “中间”); //假

Instructions

修改函数checkObj以测试myObjcheckProp 。如果找到该属性,则返回该属性的值。如果没有,请返回"Not Found"

Tests

tests:
  - text: <code>checkObj(&quot;gift&quot;)</code>应该返回<code>&quot;pony&quot;</code> 。
    testString: assert(checkObj("gift") === "pony");
  - text: <code>checkObj(&quot;pet&quot;)</code>应该返回<code>&quot;kitten&quot;</code> 。
    testString: assert(checkObj("pet") === "kitten");
  - text: <code>checkObj(&quot;house&quot;)</code>应该返回<code>&quot;Not Found&quot;</code> 。
    testString: assert(checkObj("house") === "Not Found");

Challenge Seed

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");

Solution

// solution required