Build a Project Idea Board - Build a Project Idea Board

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

Hi there,

The only thing I found was the fact that idea is not in the this scope here:

BUT…fixing that syntax error did not pass the tests. And while I like your guarding conditional check, the tests don’t. If you change this bit:

to:

your code should pass.

The hint was really off since the issue had nothing to do with the formatToString() method.

Thanks so much! I think it would have taken me quite some time to figure that out.

You’re welcome. I’ve created an issue for this:

Project Idea Board: Tests balk at guarding conditional and reference wrong hint · Issue #61089 · freeCodeCamp/freeCodeCamp

I don’t think this was our challenge causing the issue.

Rather it was a syntax error on your end.

There is no window for alert to come from. This challenge only uses a single javascript file. Kind of like working with NodeJS.

Secondly the this keyword refers to the instance the class was associated with. There is no idea property defined on the ProjectIdeaBoard class. I think you were trying to use the parameter in the unpin method.