Tell us what’s happening:
Stuck on 17. When new ProjectIdeaBoard(“Empty Board”) is empty, emptyBoard.formatToString() should return Empty Board has 0 idea(s)\n.
My console output looks good. Could use a hint - thanks.
Your code so far
const projectStatus = {
PENDING: {description: "Pending Execution"},
SUCCESS: {description: "Executed Successfully"},
FAILURE: {description: "Execution Failed"}
};
/* ====================================== */
class ProjectIdea {
constructor (title, description) {
this.title = title;
this.description = description;
this.status = projectStatus.PENDING;
/*console.log(this.status.description)*/
}
updateProjectStatus(newStatus) {
this.status = newStatus;
}
}
/* ====================================== */
class ProjectIdeaBoard {
constructor (title) {
this.title = title;
this.ideas = [];
}
pin(idea) {
this.ideas.push(idea);
}
unpin(idea) {
const index = this.ideas.findIndex(obj => obj.title === idea.title);
if (index !== -1) {
this.ideas.splice(index,1);
} else {
alert(`Idea not found: ${this.idea.title}`);
}
}
count() {
return this.ideas.length;
}
formatToString() {
const count = this.count();
let ideasSummary = `${this.title} has ${count} idea(s)\n`;
if (count > 0) {
this.ideas.forEach(idea => {
ideasSummary +=
`${idea.title} (${idea.status.description}) - ${idea.description}\n`;
});
}
return ideasSummary;
}
}
/* ---------- test cases ----------------- */
const emptyBoard = new ProjectIdeaBoard("Empty Board");
console.log(emptyBoard.formatToString());
/*
const techProjects = new ProjectIdeaBoard("Tech Projects Board");
const projIdea = new ProjectIdea("Smart Home System", "An integrated system to control lighting, temperature, and security devices remotely.")
techProjects.pin(projIdea);
/*console.log(techProjects)
console.log(techProjects.formatToString());
*/
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Build a Project Idea Board - Build a Project Idea Board