Tell us what’s happening:
My solution is not being recognized although it is already showing the expected result on the freecodecamp’s console.
It keeps showing this:
buildSummary should build the summary from any artifact’s own values, one field per line and in order.
console:
Golden Mask
Category: Ceremonial
Curator: Fran Sinclair
Current Gallery: Hall C
On Display: true
Your code so far
const collection = {
101: {
title: "Golden Mask",
category: "Ceremonial",
curator: {
id: 201,
name: "Earl Sinclair",
},
locations: [
{ gallery: "Hall A", year: 2020 },
{ gallery: "Hall C", year: 2024 },
],
tags: ["gold", "egypt"],
onDisplay: true,
},
102: {
title: "Bronze Tablet",
category: "Inscription",
curator: {
id: 202,
name: "Robert Sinclair",
},
locations: [{ gallery: "Archive Wing", year: 2019 }],
tags: ["bronze", "writing"],
onDisplay: false,
},
};
console.log(collection[101].title);
console.log(collection[101].curator.name);
function getArtifactTitle(id) {
const artifact = collection[id];
return artifact ? artifact.title : "Artifact not found";
}
console.log(getArtifactTitle(102));
function addTag(id, tag) {
const artifact = collection[id];
if (artifact && !artifact.tags.includes(tag)) {
artifact.tags.push(tag);
}
}
addTag(101, "royal");
console.log(collection[101].tags);
function moveArtifact(id, gallery, year) {
const artifact = collection[id];
if (artifact) {
artifact.locations.push({ gallery, year });
}
}
moveArtifact(102, "Hall B", 2026);
console.log(collection[102].locations);
function toggleDisplayStatus(id) {
const artifact = collection[id];
if (artifact) {
artifact.onDisplay = !artifact.onDisplay;
}
}
console.log(collection[102].onDisplay);
toggleDisplayStatus(102);
console.log(collection[102].onDisplay);
function updateCurator(id, name) {
const artifact = collection[id];
if (artifact) {
artifact.curator.name = name;
}
}
updateCurator(101, "Fran Sinclair");
console.log(collection[101].curator.name);
function buildSummary(id) {
const artifact = collection[id];
if (!artifact) {
return "Artifact not found";
}
const currentLocation = artifact.locations[artifact.locations.length - 1];
// User Editable Region
return `
${artifact.title}
Category: ${artifact.category}
Curator: ${artifact.curator.name}
Current Gallery: ${artifact.locations[artifact.locations.length-1].gallery}
On Display: ${artifact.onDisplay}
`;
// User Editable Region
}
console.log(buildSummary(101));
even if I use currentLocation.gallery as in:
return `
${artifact.title}
Category: ${artifact.category}
Curator: ${artifact.curator.name}
Current Gallery: ${currentLocation.gallery}
On Display: ${artifact.onDisplay}
`;
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36
Challenge Information:
Build an Artifact Provenance Auditor - Step 19