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: 100}]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"TODO
console.log(extractClassName("Live-Session Class 2022 September")); // "2022-09"
console.log(extractClassName("Live-Session Class 2022 März")); // "2022-03"
console.log(extractClassName("Live-Session Class 2022 Maerz")); // "2022-03"
console.log(extractClassName("Live-Session 2022 April")); // null
console.log(extractClassName("Live-Session Class 2 X")); // null
console.log(extractClassName("Live-Session Class 2022 Y")); // null
console.log(extractClassName("Live-Session Class 22 April")); // null