chore: bring in korean translations (#53620)

This commit is contained in:
Mama Naomi
2024-02-09 00:14:01 -08:00
committed by GitHub
parent 060adcc1be
commit 878f112d6f
11174 changed files with 1662588 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
---
id: a77dbc43c33f39daa4429b4f
title: Boo who
challengeType: 1
forumTopicId: 16000
dashedName: boo-who
---
# --description--
Check if a value is classified as a boolean primitive. Return `true` or `false`.
Boolean primitives are `true` and `false`.
# --hints--
`booWho(true)` should return `true`.
```js
assert.strictEqual(booWho(true), true);
```
`booWho(false)` should return `true`.
```js
assert.strictEqual(booWho(false), true);
```
`booWho([1, 2, 3])` should return `false`.
```js
assert.strictEqual(booWho([1, 2, 3]), false);
```
`booWho([].slice)` should return `false`.
```js
assert.strictEqual(booWho([].slice), false);
```
`booWho({ "a": 1 })` should return `false`.
```js
assert.strictEqual(booWho({ a: 1 }), false);
```
`booWho(1)` should return `false`.
```js
assert.strictEqual(booWho(1), false);
```
`booWho(NaN)` should return `false`.
```js
assert.strictEqual(booWho(NaN), false);
```
`booWho("a")` should return `false`.
```js
assert.strictEqual(booWho('a'), false);
```
`booWho("true")` should return `false`.
```js
assert.strictEqual(booWho('true'), false);
```
`booWho("false")` should return `false`.
```js
assert.strictEqual(booWho('false'), false);
```
# --seed--
## --seed-contents--
```js
function booWho(bool) {
return bool;
}
booWho(null);
```
# --solutions--
```js
function booWho(bool) {
return typeof bool === "boolean";
}
booWho(null);
```

View File

@@ -0,0 +1,110 @@
---
id: a9bd25c716030ec90084d8a1
title: Chunky Monkey
challengeType: 1
forumTopicId: 16005
dashedName: chunky-monkey
---
# --description--
Write a function that splits an array (first argument) into groups the length of `size` (second argument) and returns them as a two-dimensional array.
# --hints--
`chunkArrayInGroups(["a", "b", "c", "d"], 2)` should return `[["a", "b"], ["c", "d"]]`.
```js
assert.deepEqual(chunkArrayInGroups(['a', 'b', 'c', 'd'], 2), [
['a', 'b'],
['c', 'd']
]);
```
`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)` should return `[[0, 1, 2], [3, 4, 5]]`.
```js
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [
[0, 1, 2],
[3, 4, 5]
]);
```
`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)` should return `[[0, 1], [2, 3], [4, 5]]`.
```js
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [
[0, 1],
[2, 3],
[4, 5]
]);
```
`chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)` should return `[[0, 1, 2, 3], [4, 5]]`.
```js
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [
[0, 1, 2, 3],
[4, 5]
]);
```
`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)` should return `[[0, 1, 2], [3, 4, 5], [6]]`.
```js
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [
[0, 1, 2],
[3, 4, 5],
[6]
]);
```
`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)` should return `[[0, 1, 2, 3], [4, 5, 6, 7], [8]]`.
```js
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [
[0, 1, 2, 3],
[4, 5, 6, 7],
[8]
]);
```
`chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)` should return `[[0, 1], [2, 3], [4, 5], [6, 7], [8]]`.
```js
assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [
[0, 1],
[2, 3],
[4, 5],
[6, 7],
[8]
]);
```
# --seed--
## --seed-contents--
```js
function chunkArrayInGroups(arr, size) {
return arr;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
```
# --solutions--
```js
function chunkArrayInGroups(arr, size) {
let out = [];
for (let i = 0; i < arr.length; i += size) {
out.push(arr.slice(i, i + size));
}
return out;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
```

View File

@@ -0,0 +1,113 @@
---
id: acda2fb1324d9b0fa741e6b5
title: Confirm the Ending
challengeType: 1
forumTopicId: 16006
dashedName: confirm-the-ending
---
# --description--
Check if a string (first argument, `str`) ends with the given target string (second argument, `target`).
This challenge *can* be solved with the `.endsWith()` method, which was introduced in ES2015. But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.
# --hints--
`confirmEnding("Bastian", "n")` should return `true`.
```js
assert(confirmEnding('Bastian', 'n') === true);
```
`confirmEnding("Congratulation", "on")` should return `true`.
```js
assert(confirmEnding('Congratulation', 'on') === true);
```
`confirmEnding("Connor", "n")` should return `false`.
```js
assert(confirmEnding('Connor', 'n') === false);
```
`confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")` should return `false`.
```js
assert(
confirmEnding(
'Walking on water and developing software from a specification are easy if both are frozen',
'specification'
) === false
);
```
`confirmEnding("He has to give me a new name", "name")` should return `true`.
```js
assert(confirmEnding('He has to give me a new name', 'name') === true);
```
`confirmEnding("Open sesame", "same")` should return `true`.
```js
assert(confirmEnding('Open sesame', 'same') === true);
```
`confirmEnding("Open sesame", "sage")` should return `false`.
```js
assert(confirmEnding('Open sesame', 'sage') === false);
```
`confirmEnding("Open sesame", "game")` should return `false`.
```js
assert(confirmEnding('Open sesame', 'game') === false);
```
`confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")` should return `false`.
```js
assert(
confirmEnding(
'If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing',
'mountain'
) === false
);
```
`confirmEnding("Abstraction", "action")` should return `true`.
```js
assert(confirmEnding('Abstraction', 'action') === true);
```
Your code should not use the built-in method `.endsWith()` to solve the challenge.
```js
assert(!/\.endsWith\(.*?\)\s*?;?/.test(code) && !/\['endsWith'\]/.test(code));
```
# --seed--
## --seed-contents--
```js
function confirmEnding(str, target) {
return str;
}
confirmEnding("Bastian", "n");
```
# --solutions--
```js
function confirmEnding(str, target) {
return str.substring(str.length - target.length) === target;
}
confirmEnding("Bastian", "n");
```

View File

@@ -0,0 +1,75 @@
---
id: 56533eb9ac21ba0edf2244b3
title: Convert Celsius to Fahrenheit
challengeType: 1
forumTopicId: 16806
dashedName: convert-celsius-to-fahrenheit
---
# --description--
The formula to convert from Celsius to Fahrenheit is the temperature in Celsius times `9/5`, plus `32`.
You are given a variable `celsius` representing a temperature in Celsius. Use the variable `fahrenheit` already defined and assign it the Fahrenheit temperature equivalent to the given Celsius temperature. Use the formula mentioned above to help convert the Celsius temperature to Fahrenheit.
# --hints--
`convertCtoF(0)` should return a number
```js
assert(typeof convertCtoF(0) === 'number');
```
`convertCtoF(-30)` should return a value of `-22`
```js
assert(convertCtoF(-30) === -22);
```
`convertCtoF(-10)` should return a value of `14`
```js
assert(convertCtoF(-10) === 14);
```
`convertCtoF(0)` should return a value of `32`
```js
assert(convertCtoF(0) === 32);
```
`convertCtoF(20)` should return a value of `68`
```js
assert(convertCtoF(20) === 68);
```
`convertCtoF(30)` should return a value of `86`
```js
assert(convertCtoF(30) === 86);
```
# --seed--
## --seed-contents--
```js
function convertCtoF(celsius) {
let fahrenheit;
return fahrenheit;
}
convertCtoF(30);
```
# --solutions--
```js
function convertCtoF(celsius) {
let fahrenheit = celsius * 9/5 + 32;
return fahrenheit;
}
convertCtoF(30);
```

View File

@@ -0,0 +1,73 @@
---
id: a302f7aae1aa3152a5b413bc
title: Factorialize a Number
challengeType: 1
forumTopicId: 16013
dashedName: factorialize-a-number
---
# --description--
Return the factorial of the provided integer.
If the integer is represented with the letter `n`, a factorial is the product of all positive integers less than or equal to `n`.
Factorials are often represented with the shorthand notation `n!`
For example: `5! = 1 * 2 * 3 * 4 * 5 = 120`
Only integers greater than or equal to zero will be supplied to the function.
# --hints--
`factorialize(5)` should return a number.
```js
assert(typeof factorialize(5) === 'number');
```
`factorialize(5)` should return `120`.
```js
assert(factorialize(5) === 120);
```
`factorialize(10)` should return `3628800`.
```js
assert(factorialize(10) === 3628800);
```
`factorialize(20)` should return `2432902008176640000`.
```js
assert(factorialize(20) === 2432902008176640000);
```
`factorialize(0)` should return `1`.
```js
assert(factorialize(0) === 1);
```
# --seed--
## --seed-contents--
```js
function factorialize(num) {
return num;
}
factorialize(5);
```
# --solutions--
```js
function factorialize(num) {
return num < 1 ? 1 : num * factorialize(num - 1);
}
factorialize(5);
```

View File

@@ -0,0 +1,71 @@
---
id: adf08ec01beb4f99fc7a68f2
title: Falsy Bouncer
challengeType: 1
forumTopicId: 16014
dashedName: falsy-bouncer
---
# --description--
Remove all falsy values from an array. Return a new array; do not mutate the original array.
Falsy values in JavaScript are `false`, `null`, `0`, `""`, `undefined`, and `NaN`.
Hint: Try converting each value to a Boolean.
# --hints--
`bouncer([7, "ate", "", false, 9])` should return `[7, "ate", 9]`.
```js
assert.deepEqual(bouncer([7, 'ate', '', false, 9]), [7, 'ate', 9]);
```
`bouncer(["a", "b", "c"])` should return `["a", "b", "c"]`.
```js
assert.deepEqual(bouncer(['a', 'b', 'c']), ['a', 'b', 'c']);
```
`bouncer([false, null, 0, NaN, undefined, ""])` should return `[]`.
```js
assert.deepEqual(bouncer([false, null, 0, NaN, undefined, '']), []);
```
`bouncer([null, NaN, 1, 2, undefined])` should return `[1, 2]`.
```js
assert.deepEqual(bouncer([null, NaN, 1, 2, undefined]), [1, 2]);
```
You should not mutate `arr`.
```js
const arr = ['a', false, 0, 'Naomi'];
bouncer(arr);
assert.deepEqual(arr, ['a', false, 0, 'Naomi'])
```
# --seed--
## --seed-contents--
```js
function bouncer(arr) {
return arr;
}
bouncer([7, "ate", "", false, 9]);
```
# --solutions--
```js
function bouncer(arr) {
return arr.filter(e => e);
}
bouncer([7, "ate", "", false, 9]);
```

View File

@@ -0,0 +1,87 @@
---
id: a26cbbe9ad8655a977e1ceb5
title: Find the Longest Word in a String
challengeType: 1
forumTopicId: 16015
dashedName: find-the-longest-word-in-a-string
---
# --description--
Return the length of the longest word in the provided sentence.
Your response should be a number.
# --hints--
`findLongestWordLength("The quick brown fox jumped over the lazy dog")` should return a number.
```js
assert(
typeof findLongestWordLength(
'The quick brown fox jumped over the lazy dog'
) === 'number'
);
```
`findLongestWordLength("The quick brown fox jumped over the lazy dog")` should return `6`.
```js
assert(
findLongestWordLength('The quick brown fox jumped over the lazy dog') === 6
);
```
`findLongestWordLength("May the force be with you")` should return `5`.
```js
assert(findLongestWordLength('May the force be with you') === 5);
```
`findLongestWordLength("Google do a barrel roll")` should return `6`.
```js
assert(findLongestWordLength('Google do a barrel roll') === 6);
```
`findLongestWordLength("What is the average airspeed velocity of an unladen swallow")` should return `8`.
```js
assert(
findLongestWordLength(
'What is the average airspeed velocity of an unladen swallow'
) === 8
);
```
`findLongestWordLength("What if we try a super-long word such as otorhinolaryngology")` should return `19`.
```js
assert(
findLongestWordLength(
'What if we try a super-long word such as otorhinolaryngology'
) === 19
);
```
# --seed--
## --seed-contents--
```js
function findLongestWordLength(str) {
return str.length;
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
```
# --solutions--
```js
function findLongestWordLength(str) {
return str.split(' ').sort((a, b) => b.length - a.length)[0].length;
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
```

View File

@@ -0,0 +1,58 @@
---
id: a6e40f1041b06c996f7b2406
title: Finders Keepers
challengeType: 1
forumTopicId: 16016
dashedName: finders-keepers
---
# --description--
Create a function that looks through an array `arr` and returns the first element in it that passes a 'truth test'. This means that given an element `x`, the 'truth test' is passed if `func(x)` is `true`. If no element passes the test, return `undefined`.
# --hints--
`findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })` should return `8`.
```js
assert.strictEqual(
findElement([1, 3, 5, 8, 9, 10], function (num) {
return num % 2 === 0;
}),
8
);
```
`findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; })` should return `undefined`.
```js
assert.strictEqual(
findElement([1, 3, 5, 9], function (num) {
return num % 2 === 0;
}),
undefined
);
```
# --seed--
## --seed-contents--
```js
function findElement(arr, func) {
let num = 0;
return num;
}
findElement([1, 2, 3, 4], num => num % 2 === 0);
```
# --solutions--
```js
function findElement(arr, func) {
return arr.filter(func)[0];
}
findElement([1, 2, 3, 4], num => num % 2 === 0);
```

View File

@@ -0,0 +1,117 @@
---
id: af2170cad53daa0770fabdea
title: Mutations
challengeType: 1
forumTopicId: 16025
dashedName: mutations
---
# --description--
Return `true` if the string in the first element of the array contains all of the letters of the string in the second element of the array.
For example, `["hello", "Hello"]`, should return `true` because all of the letters in the second string are present in the first, ignoring case.
The arguments `["hello", "hey"]` should return `false` because the string `hello` does not contain a `y`.
Lastly, `["Alien", "line"]`, should return `true` because all of the letters in `line` are present in `Alien`.
# --hints--
`mutation(["hello", "hey"])` should return `false`.
```js
assert(mutation(['hello', 'hey']) === false);
```
`mutation(["hello", "Hello"])` should return `true`.
```js
assert(mutation(['hello', 'Hello']) === true);
```
`mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])` should return `true`.
```js
assert(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu']) === true);
```
`mutation(["Mary", "Army"])` should return `true`.
```js
assert(mutation(['Mary', 'Army']) === true);
```
`mutation(["Mary", "Aarmy"])` should return `true`.
```js
assert(mutation(['Mary', 'Aarmy']) === true);
```
`mutation(["Alien", "line"])` should return `true`.
```js
assert(mutation(['Alien', 'line']) === true);
```
`mutation(["floor", "for"])` should return `true`.
```js
assert(mutation(['floor', 'for']) === true);
```
`mutation(["hello", "neo"])` should return `false`.
```js
assert(mutation(['hello', 'neo']) === false);
```
`mutation(["voodoo", "no"])` should return `false`.
```js
assert(mutation(['voodoo', 'no']) === false);
```
`mutation(["ate", "date"])` should return `false`.
```js
assert(mutation(['ate', 'date']) === false);
```
`mutation(["Tiger", "Zebra"])` should return `false`.
```js
assert(mutation(['Tiger', 'Zebra']) === false);
```
`mutation(["Noel", "Ole"])` should return `true`.
```js
assert(mutation(['Noel', 'Ole']) === true);
```
# --seed--
## --seed-contents--
```js
function mutation(arr) {
return arr;
}
mutation(["hello", "hey"]);
```
# --solutions--
```js
function mutation(arr) {
let hash = Object.create(null);
arr[0].toLowerCase().split('').forEach(c => hash[c] = true);
return !arr[1].toLowerCase().split('').filter(c => !hash[c]).length;
}
mutation(["hello", "hey"]);
```

View File

@@ -0,0 +1,84 @@
---
id: afcc8d540bea9ea2669306b6
title: Repeat a String Repeat a String
challengeType: 1
forumTopicId: 16041
dashedName: repeat-a-string-repeat-a-string
---
# --description--
Repeat a given string `str` (first argument) for `num` times (second argument). Return an empty string if `num` is not a positive number. For the purpose of this challenge, do *not* use the built-in `.repeat()` method.
# --hints--
`repeatStringNumTimes("*", 3)` should return the string `***`.
```js
assert(repeatStringNumTimes('*', 3) === '***');
```
`repeatStringNumTimes("abc", 3)` should return the string `abcabcabc`.
```js
assert(repeatStringNumTimes('abc', 3) === 'abcabcabc');
```
`repeatStringNumTimes("abc", 4)` should return the string `abcabcabcabc`.
```js
assert(repeatStringNumTimes('abc', 4) === 'abcabcabcabc');
```
`repeatStringNumTimes("abc", 1)` should return the string `abc`.
```js
assert(repeatStringNumTimes('abc', 1) === 'abc');
```
`repeatStringNumTimes("*", 8)` should return the string `********`.
```js
assert(repeatStringNumTimes('*', 8) === '********');
```
`repeatStringNumTimes("abc", -2)` should return an empty string (`""`).
```js
assert(repeatStringNumTimes('abc', -2) === '');
```
The built-in `repeat()` method should not be used.
```js
assert(!/\.repeat/g.test(code));
```
`repeatStringNumTimes("abc", 0)` should return `""`.
```js
assert(repeatStringNumTimes('abc', 0) === '');
```
# --seed--
## --seed-contents--
```js
function repeatStringNumTimes(str, num) {
return str;
}
repeatStringNumTimes("abc", 3);
```
# --solutions--
```js
function repeatStringNumTimes(str, num) {
if (num < 1) return '';
return num === 1 ? str : str + repeatStringNumTimes(str, num-1);
}
repeatStringNumTimes("abc", 3);
```

View File

@@ -0,0 +1,92 @@
---
id: a789b3483989747d63b0e427
title: Return Largest Numbers in Arrays
challengeType: 1
forumTopicId: 16042
dashedName: return-largest-numbers-in-arrays
---
# --description--
Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.
Remember, you can iterate through an array with a simple for loop, and access each member with array syntax `arr[i]`.
# --hints--
`largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])` should return an array.
```js
assert(
largestOfFour([
[4, 5, 1, 3],
[13, 27, 18, 26],
[32, 35, 37, 39],
[1000, 1001, 857, 1]
]).constructor === Array
);
```
`largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])` should return `[27, 5, 39, 1001]`.
```js
assert.deepEqual(
largestOfFour([
[13, 27, 18, 26],
[4, 5, 1, 3],
[32, 35, 37, 39],
[1000, 1001, 857, 1]
]),
[27, 5, 39, 1001]
);
```
`largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]])` should return `[9, 35, 97, 1000000]`.
```js
assert.deepEqual(
largestOfFour([
[4, 9, 1, 3],
[13, 35, 18, 26],
[32, 35, 97, 39],
[1000000, 1001, 857, 1]
]),
[9, 35, 97, 1000000]
);
```
`largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])` should return `[25, 48, 21, -3]`.
```js
assert.deepEqual(
largestOfFour([
[17, 23, 25, 12],
[25, 7, 34, 48],
[4, -10, 18, 21],
[-72, -3, -17, -10]
]),
[25, 48, 21, -3]
);
```
# --seed--
## --seed-contents--
```js
function largestOfFour(arr) {
return arr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
```
# --solutions--
```js
function largestOfFour(arr) {
return arr.map(subArr => Math.max.apply(null, subArr));
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
```

View File

@@ -0,0 +1,61 @@
---
id: a202eed8fc186c8434cb6d61
title: Reverse a String
challengeType: 1
forumTopicId: 16043
dashedName: reverse-a-string
---
# --description--
Reverse the provided string and return the reversed string.
For example, `"hello"` should become `"olleh"`.
# --hints--
`reverseString("hello")` should return a string.
```js
assert(typeof reverseString('hello') === 'string');
```
`reverseString("hello")` should return the string `olleh`.
```js
assert(reverseString('hello') === 'olleh');
```
`reverseString("Howdy")` should return the string `ydwoH`.
```js
assert(reverseString('Howdy') === 'ydwoH');
```
`reverseString("Greetings from Earth")` should return the string `htraE morf sgniteerG`.
```js
assert(reverseString('Greetings from Earth') === 'htraE morf sgniteerG');
```
# --seed--
## --seed-contents--
```js
function reverseString(str) {
return str;
}
reverseString("hello");
```
# --solutions--
```js
function reverseString(str) {
return str.split('').reverse().join('');
}
reverseString("hello");
```

View File

@@ -0,0 +1,98 @@
---
id: 579e2a2c335b9d72dd32e05c
title: Slice and Splice
challengeType: 1
forumTopicId: 301148
dashedName: slice-and-splice
---
# --description--
You are given two arrays and an index.
Copy each element of the first array into the second array, in order.
Begin inserting elements at index `n` of the second array.
Return the resulting array. The input arrays should remain the same after the function runs.
# --hints--
`frankenSplice([1, 2, 3], [4, 5], 1)` should return `[4, 1, 2, 3, 5]`.
```js
assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5]);
```
`frankenSplice([1, 2], ["a", "b"], 1)` should return `["a", 1, 2, "b"]`.
```js
assert.deepEqual(frankenSplice(testArr1, testArr2, 1), ['a', 1, 2, 'b']);
```
`frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)` should return `["head", "shoulders", "claw", "tentacle", "knees", "toes"]`.
```js
assert.deepEqual(
frankenSplice(
['claw', 'tentacle'],
['head', 'shoulders', 'knees', 'toes'],
2
),
['head', 'shoulders', 'claw', 'tentacle', 'knees', 'toes']
);
```
All elements from the first array should be added to the second array in their original order. `frankenSplice([1, 2, 3, 4], [], 0)` should return `[1, 2, 3, 4]`.
```js
assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4]);
```
The first array should remain the same after the function runs.
```js
frankenSplice(testArr1, testArr2, 1);
assert.deepEqual(testArr1, [1, 2]);
```
The second array should remain the same after the function runs.
```js
frankenSplice(testArr1, testArr2, 1);
assert.deepEqual(testArr2, ['a', 'b']);
```
# --seed--
## --after-user-code--
```js
let testArr1 = [1, 2];
let testArr2 = ["a", "b"];
```
## --seed-contents--
```js
function frankenSplice(arr1, arr2, n) {
return arr2;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
```
# --solutions--
```js
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
let result = arr2.slice();
for (let i = 0; i < arr1.length; i++) {
result.splice(n+i, 0, arr1[i]);
}
return result;
}
frankenSplice([1, 2, 3], [4, 5], 1);
```

View File

@@ -0,0 +1,64 @@
---
id: ab6137d4e35944e21037b769
title: Title Case a Sentence
challengeType: 1
forumTopicId: 16088
dashedName: title-case-a-sentence
---
# --description--
Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.
For the purpose of this exercise, you should also capitalize connecting words like `the` and `of`.
# --hints--
`titleCase("I'm a little tea pot")` should return a string.
```js
assert(typeof titleCase("I'm a little tea pot") === 'string');
```
`titleCase("I'm a little tea pot")` should return the string `I'm A Little Tea Pot`.
```js
assert(titleCase("I'm a little tea pot") === "I'm A Little Tea Pot");
```
`titleCase("sHoRt AnD sToUt")` should return the string `Short And Stout`.
```js
assert(titleCase('sHoRt AnD sToUt') === 'Short And Stout');
```
`titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")` should return the string `Here Is My Handle Here Is My Spout`.
```js
assert(
titleCase('HERE IS MY HANDLE HERE IS MY SPOUT') ===
'Here Is My Handle Here Is My Spout'
);
```
# --seed--
## --seed-contents--
```js
function titleCase(str) {
return str;
}
titleCase("I'm a little tea pot");
```
# --solutions--
```js
function titleCase(str) {
return str.split(' ').map(word => word.charAt(0).toUpperCase() + word.substring(1).toLowerCase()).join(' ');
}
titleCase("I'm a little tea pot");
```

View File

@@ -0,0 +1,91 @@
---
id: ac6993d51946422351508a41
title: Truncate a String
challengeType: 1
forumTopicId: 16089
dashedName: truncate-a-string
---
# --description--
Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a `...` ending.
# --hints--
`truncateString("A-tisket a-tasket A green and yellow basket", 8)` should return the string `A-tisket...`.
```js
assert(
truncateString('A-tisket a-tasket A green and yellow basket', 8) ===
'A-tisket...'
);
```
`truncateString("Peter Piper picked a peck of pickled peppers", 11)` should return the string `Peter Piper...`.
```js
assert(
truncateString('Peter Piper picked a peck of pickled peppers', 11) ===
'Peter Piper...'
);
```
`truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length)` should return the string `A-tisket a-tasket A green and yellow basket`.
```js
assert(
truncateString(
'A-tisket a-tasket A green and yellow basket',
'A-tisket a-tasket A green and yellow basket'.length
) === 'A-tisket a-tasket A green and yellow basket'
);
```
`truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2)` should return the string `A-tisket a-tasket A green and yellow basket`.
```js
assert(
truncateString(
'A-tisket a-tasket A green and yellow basket',
'A-tisket a-tasket A green and yellow basket'.length + 2
) === 'A-tisket a-tasket A green and yellow basket'
);
```
`truncateString("A-", 1)` should return the string `A...`.
```js
assert(truncateString('A-', 1) === 'A...');
```
`truncateString("Absolutely Longer", 2)` should return the string `Ab...`.
```js
assert(truncateString('Absolutely Longer', 2) === 'Ab...');
```
# --seed--
## --seed-contents--
```js
function truncateString(str, num) {
return str;
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);
```
# --solutions--
```js
function truncateString(str, num) {
if (num >= str.length) {
return str;
}
return str.slice(0, num) + '...';
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);
```

View File

@@ -0,0 +1,143 @@
---
id: a24c1a4622e3c05097f71d67
title: Where do I Belong
challengeType: 1
forumTopicId: 16094
dashedName: where-do-i-belong
---
# --description--
Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number.
For example, `getIndexToIns([1,2,3,4], 1.5)` should return `1` because it is greater than `1` (index 0), but less than `2` (index 1).
Likewise, `getIndexToIns([20,3,5], 19)` should return `2` because once the array has been sorted it will look like `[3,5,20]` and `19` is less than `20` (index 2) and greater than `5` (index 1).
# --hints--
`getIndexToIns([10, 20, 30, 40, 50], 35)` should return `3`.
```js
assert(getIndexToIns([10, 20, 30, 40, 50], 35) === 3);
```
`getIndexToIns([10, 20, 30, 40, 50], 35)` should return a number.
```js
assert(typeof getIndexToIns([10, 20, 30, 40, 50], 35) === 'number');
```
`getIndexToIns([10, 20, 30, 40, 50], 30)` should return `2`.
```js
assert(getIndexToIns([10, 20, 30, 40, 50], 30) === 2);
```
`getIndexToIns([10, 20, 30, 40, 50], 30)` should return a number.
```js
assert(typeof getIndexToIns([10, 20, 30, 40, 50], 30) === 'number');
```
`getIndexToIns([40, 60], 50)` should return `1`.
```js
assert(getIndexToIns([40, 60], 50) === 1);
```
`getIndexToIns([40, 60], 50)` should return a number.
```js
assert(typeof getIndexToIns([40, 60], 50) === 'number');
```
`getIndexToIns([3, 10, 5], 3)` should return `0`.
```js
assert(getIndexToIns([3, 10, 5], 3) === 0);
```
`getIndexToIns([3, 10, 5], 3)` should return a number.
```js
assert(typeof getIndexToIns([3, 10, 5], 3) === 'number');
```
`getIndexToIns([5, 3, 20, 3], 5)` should return `2`.
```js
assert(getIndexToIns([5, 3, 20, 3], 5) === 2);
```
`getIndexToIns([5, 3, 20, 3], 5)` should return a number.
```js
assert(typeof getIndexToIns([5, 3, 20, 3], 5) === 'number');
```
`getIndexToIns([2, 20, 10], 19)` should return `2`.
```js
assert(getIndexToIns([2, 20, 10], 19) === 2);
```
`getIndexToIns([2, 20, 10], 19)` should return a number.
```js
assert(typeof getIndexToIns([2, 20, 10], 19) === 'number');
```
`getIndexToIns([2, 5, 10], 15)` should return `3`.
```js
assert(getIndexToIns([2, 5, 10], 15) === 3);
```
`getIndexToIns([2, 5, 10], 15)` should return a number.
```js
assert(typeof getIndexToIns([2, 5, 10], 15) === 'number');
```
`getIndexToIns([], 1)` should return `0`.
```js
assert(getIndexToIns([], 1) === 0);
```
`getIndexToIns([], 1)` should return a number.
```js
assert(typeof getIndexToIns([], 1) === 'number');
```
# --seed--
## --seed-contents--
```js
function getIndexToIns(arr, num) {
return num;
}
getIndexToIns([40, 60], 50);
```
# --solutions--
```js
function getIndexToIns(arr, num) {
arr = arr.sort((a, b) => a - b);
for (let i = 0; i < arr.length; i++) {
if (arr[i] >= num) {
return i;
}
}
return arr.length;
}
getIndexToIns([40, 60], 50);
```