Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.2 KiB

id, title, challengeType, videoUrl, dashedName
id title challengeType videoUrl dashedName
596a8888ab7c01048de257d5 deepcopy的 5 deepcopy

--description--

任务:

编写一个返回给定对象的深层副本的函数。

副本不得与给定的对象相同。

此任务不会测试:

具有属性属性的对象Date对象或具有Date对象属性的对象RegEx或具有RegEx对象属性的对象原型复制

--hints--

deepcopy应该是一个功能。

assert(typeof deepcopy === 'function');

deepcopy({test: "test"})应返回一个对象。

assert(typeof deepcopy(obj1) === 'object');

不应该返回提供的相同对象。

assert(deepcopy(obj2) != obj2);

传递包含数组的对象时,应返回该对象的深层副本。

assert.deepEqual(deepcopy(obj2), obj2);

传递包含另一个对象的对象时,应返回该对象的深层副本。

assert.deepEqual(deepcopy(obj3), obj3);

--seed--

--after-user-code--

const obj1 = { test: 'test' };
const obj2 = {
  t: 'test',
  a: ['an', 'array']
};
const obj3 = {
  t: 'try',
  o: obj2
};

--seed-contents--

function deepcopy(obj) {

  return true;
}

--solutions--

function deepcopy(obj) {
  return JSON.parse(JSON.stringify(obj));
}