Tell us what’s happening:
not passing number 17
but I have the correct format
if I force count to be 0 count = 0; then it passes but then the 18 does not pass
seems like the issue is with return ${this.title} has 0 idea(s)\n
yet I have the format that is requested
formatToString() {
let count = this.count(); // count() returns the number of ideas
if (count === 0) {
return ${this.title} has 0 idea(s)\n
; // When no ideas are present
}
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(ProjectIdea){
//ideas.pop(ProjectIdea)
this.ideas.pop();
}
count(){
return ProjectIdeaBoard.length;
}
/*
formatToString() {
const count = this.count();
if (count === 0) {
return `${this.title} has 0 idea(s)\n`;
return `${this.title} has 0 idea(s)\n`; // Should work for empty board
}
const projectIdeas = this.ideas
.map((idea) => idea.toString())
.join('');
return `${this.title} has ${count} idea(s)\n${projectIdeas}`;
}
}*/
formatToString() {
let count = this.count(); // Assuming count() returns the number of ideas
if (count === 0) {
return `${this.title} has 0 idea(s)\n`; // When no ideas are present
}
const projectIdeas = this.ideas
.map((idea) => idea.toString()) // Assuming 'toString()' is defined on ProjectIdea
.join(''); // Concatenate all ideas
return `${this.title} has ${count} idea(s)\n${projectIdeas}`; // Return formatted string
}}
// Demo for test case 17
const emptyBoard = new ProjectIdeaBoard("");
console.log(emptyBoard.formatToString()); // Empty Board has 0 ideas
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0
Challenge Information:
Build a Project Idea Board - Build a Project Idea Board