Recap - JSON Manipulate Keys
Part of the Logic & Flow section of Coddy's JavaScript journey — lesson 21 of 65.
Challenge
EasyCreate a function named petShelterManager that helps manage a pet shelter system. The function receives two parameters:
shelterData(an array of objects containing information about pets)newData(an object containing new data)
The shelterData array contains objects with the following structure:
{
id: "unique-id",
name: "pet-name",
type: "animal-type",
age: number,
isVaccinated: boolean,
adoptionStatus: "available" | "adopted"
}Your function should do the following:
- Add the newData object to the shelterData array
- Before adding, verify that all required fields (id, name, type, age, isVaccinated, adoptionStatus) exist in newData
- If a field is missing, do not add the newData
Return the updated shelterData array
Try it yourself
function petShelterManager(shelterData, newData) {
// Write code here
}
// Do not write anything outside functionAll lessons in Logic & Flow
1Strings In Depth
String FundamentalsIterate Over StringsTemplate LiteralsString MethodsRecap - String Weaver4JSON Part 2
Iterate Over JSONNested JSONJSON Optional ChainingShallow And Deep CopyRecap - Bicycle ShopRecap - Solar System10Manage Festival System
Project OverviewAdd Movies & Venues2Multi-dimensional Arrays
2D Arrays BasicsAccessing 2D Array ElementsNested Loops with 2D ArraysRecap - 2D ArraysMatrix Addition & SubstractionJagged Arrays3D Arrays And BeyondCommon 2D Array PatternsRecap - All About Arrays5Sets Part 1
What Is A Set?Iterating Over SetsAdding An ElementRemoving An ElementChecking If An Element ExistsSize And Is EmptyCopy And ClearRecap - Basic Of Sets8Arrays Interesting Topics
Array DestructuringSpread Syntax in ArraysSparse ArraysRecap - Arrays Workshop3JSON Part 1
What is a JSON?Check If Key ExistsObject MethodsThe Spread Operator Part 1The Spread Operator Part 2Remove KeysRecap - JSON Manipulate Keys