Build a Project Idea Board - Build a Project Idea Board

Tell us what’s happening:

  1. When new ProjectIdeaBoard(“Empty Board”) is empty, emptyBoard.formatToString() should return Empty Board has 0 idea(s)\n. I can’t get this to pass no matter what I do.

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(newStatus){
    this.status = newStatus
  }
}

class ProjectIdeaBoard {
  constructor(title){
    this.title = title;
    this.ideas = []
  }

  pin(obj){
    this.ideas.push(obj);
  }

  unpin(obj){
    const objIndex = this.ideas.findIndex((item)=> item.title === obj.title && item.description === obj.description);
    if(objIndex === -1){
      alert("this project idea doesn't exist")
      return
    }
    this.ideas.splice(objIndex, 1);
  }

  count(){
    return this.ideas.length
  }

  formatToString(){
    
    let returnStr = `${this.title} has ${this.count()} idea(s)\n`;
    if(this.count() === 0){
      return returnStr;
    }
    this.ideas.forEach((obj)=>{
      returnStr +=`${obj.title} (${obj.status.description}) - ${obj.description}\n`;
    })
    return returnStr;
  }
    
}



Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Project Idea Board - Build a Project Idea Board

Hey @Akeem,

I’ve opened an issue in Github about this. Your return string is correct and matches what the step expects.

ok, thank you. It just doesn’t make sense because test 18 is passing so I’m not sure why 17 would fail.

I spent easily 30 minutes because I thought I was going crazy, but your code exactly matches the expected output and is in a format that would be suitable for this project. This isn’t the first issue with this project and this particular step I found out, as well. I’ll come back here and reply when I have more answers. Until then, I would move on to other things until this is fixed.

There was a comment on the issue that says that removing the alert from the unpin causes step 17 to pass. So, there is still something wrong with this step processing, but just so you can move on, comment out/remove the alert in the unpin function.

unpin(obj){
    const objIndex = this.ideas.findIndex((item)=> item.title === obj.title && item.description === obj.description);
    if(objIndex === -1){
       //comment out the line below
      //alert("this project idea doesn't exist")
      return
    }
    this.ideas.splice(objIndex, 1);
  }

Nice! your suggestion did the trick. much appreciated. :folded_hands:

1 Like