Solve the katas with the following requirements:
- Clone this repository (on your computer)
- Delete the existing remote after cloning the repository to your computer
- Create a new branch called
checkpoint
- Solve the katas on the
checkpoint
branch - Create a new repository on GitHub called
checkpoint-coding-foundation
- Add this repository as the new origin remote to your local repository
- Push the commits to your GitHub repository
- Create a new pull request when your are done that will merge your
checkpoint
branch into themain
branch - Do not merge the branch yourself
- Assign the
codingbootcampseu
GitHub userread
permission to your repo - Assign the
codingbootcampseu
user as reviewer to your pull request
All three katas have test files that will be automatically executed when loading the index.html in the browser (please use VS Code Live Server for that).
Implement the filterApiData
function in filter-api-data.js
with the following requirements in mind.
- The first parameter
apiData
will be an array that includes objects - The objects can have different keys
- The second parameter
mandatoryKeys
is a array that includes all keys that an object (from theapiData
array) should have to pass the filter test - Return an array with only the objects that include all keys from the
mandatoryKeys
array
const data = [{ id: 1, price: 100 }, { price: 50 }];
const filteredData = filterApiData(data, ["id"]);
console.log(filteredData); // [{id: 1, price: 0}]
const data = [
{ id: 1, price: 100 },
{ id: 2, title: "" },
{ id: 3, price: 50 },
];
const filteredData = filterApiData(data, ["id", "price"]);
console.log(filteredData); // [{ id: 1, price: 100 }, { id:3, price: 50}]
Implement the SumApp
class in sum-app.js
with the following requirements in mind.
- The
sumApp
class should have a propertynumbers
which is an array - The
sumApp
class should have a methodaddNumber(n)
which will add the given number to thenumbers
array - The
sumApp
class should have a methodgetSum()
which return the sum of all numbers added to thenumbers
array- The
getSum()
method should return0
if no numbers have been added to thenumbers
array
- The
- The
sumApp
class should have a methodreset()
which should delete all numbers previously added to thenumbers
array
const sumApp = new SumApp();
sumApp.addNumber(1);
sumApp.addNumber(2);
console.log(sumApp.numbers.length); // 2
console.log(sumApp.getSum()); // 3
sumApp.reset();
console.log(sumApp.numbers.length); // 0
console.log(sumApp.getSum()); // 0
Implement a zipStrings
function in zip-strings.js
with the following requirements in mind.
- The
zipStrings
function receives two string parameters - The
zipStrings
function should return one string where the characters of both parameters are merged using the zip procedure (Reißverschlussverfahren) - Merge the strings as shown in the
Zip Strings Example
code
console.log(zipStrings("abc", "123")); // "a1b2c3"
console.log(zipStrings("abc", "1")); // "a1bc"
console.log(zipStrings("a", "123")); // "a123"
console.log(zipStrings("", "123")); // "123"
console.log(zipStrings("abc", "")); // "abc"