Tell us what’s happening:
Test case 17 doesn’t pass, even though I’ve implemented it as expected.
Please help me identify the problems I’m not seeing. What am I not considering?
Test case 17: When
new ProjectIdeaBoard("Empty Board")
is empty,emptyBoard.formatToString()
should returnEmpty Board has 0 ideas\n
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;
}
updateProjectStatus(status) {
this.status = status;
}
toString() {
return `${this.title} (${this.status.description}) - ${this.description}\n`;
}
}
class ProjectIdeaBoard {
constructor(title) {
this.title = title;
this.ideas = [];
}
pin(projectIdea) {
this.ideas.push(projectIdea);
}
unpin() {
this.ideas.pop();
}
count() {
return this.ideas.length;
}
formatToString() {
const count = this.count();
if (count === 0) {
return `${this.title} has 0 ideas\n`;
}
const projectIdeas = this.ideas
.map((idea) => idea.toString())
.join('');
return `${this.title} has ${count} idea(s)\n${projectIdeas}`;
}
}
// Demo for test case 17
const emptyBoard = new ProjectIdeaBoard("Empty Board");
console.log(emptyBoard.formatToString()); // Empty Board has 0 ideas
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Build a Project Idea Board - Build a Project Idea Board