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, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5a23c84252665b21eecc8042 Sum of squares 5 302334 sum-of-squares

--description--

Write a function to find the sum of squares of an array of integers.

--hints--

sumsq should be a function.

assert(typeof sumsq == 'function');

sumsq([1, 2, 3, 4, 5]) should return a number.

assert(typeof sumsq([1, 2, 3, 4, 5]) == 'number');

sumsq([1, 2, 3, 4, 5]) should return 55.

assert.equal(sumsq([1, 2, 3, 4, 5]), 55);

sumsq([25, 32, 12, 7, 20]) should return 2242.

assert.equal(sumsq([25, 32, 12, 7, 20]), 2242);

sumsq([38, 45, 35, 8, 13]) should return 4927.

assert.equal(sumsq([38, 45, 35, 8, 13]), 4927);

sumsq([43, 36, 20, 34, 24]) should return 5277.

assert.equal(sumsq([43, 36, 20, 34, 24]), 5277);

sumsq([12, 33, 26, 18, 1, 16, 3]) should return 2499.

assert.equal(sumsq([12, 33, 26, 18, 1, 16, 3]), 2499);

--seed--

--seed-contents--

function sumsq(array) {

}

--solutions--

function sumsq(array) {
  var sum = 0;
  var i, iLen;

  for (i = 0, iLen = array.length; i < iLen; i++) {
    sum += array[i] * array[i];
  }
  return sum;
}