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
katas-solution - Solve the katas on the
katas-solutionbranch - 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
katas-solutionbranch into themainbranch - Do not merge the branch yourself
- Assign the
codingbootcampseuGitHub userreadpermission to your repo - Assign the
codingbootcampseuuser 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
apiDatawill be an array that includes objects - The objects can have different keys
- The second parameter
mandatoryKeysis a array that includes all keys that an object (from theapiDataarray) should have to pass the filter test - Return an array with only the objects that include all keys from the
mandatoryKeysarray
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
sumAppclass should have a propertynumberswhich is an array - The
sumAppclass should have a methodaddNumber(n)which will add the given number to thenumbersarray - The
sumAppclass should have a methodgetSum()which return the sum of all numbers added to thenumbersarray- The
getSum()method should return0if no numbers have been added to thenumbersarray
- The
- The
sumAppclass should have a methodreset()which should delete all numbers previously added to thenumbersarray
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()); // 0Implement a zipStrings function in zip-strings.js with the following requirements in mind.
- The
zipStringsfunction receives two string parameters - The
zipStringsfunction 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 Examplecode
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"