Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

having a hard time with a quote generator project

im really trying to figure out the next step after /***

  • printQuote function ***/ function printQuote(message) { var result = getRandomQuote(); var message = "<p class='quote'>" + result.quote + "</p>" + "<p class='source'>" + result.source + "</p>"; }

/*** I've been working on this project of and on for 3 weeks or so with no success in cracking the concept I don't understand what it means by splitting it into 2 if statements. I've been throwing my self at this brick wall and i just cant find another way to solve this thanks

1 Answer

Hi Adrian Sanchez,

You'd likely find more help for questions like this (that deal with TechDegree projects) by seeking help in your TechDegree Slack group. That's one of the reasons it's there for you.

That said, one of the concepts the Random Quote project is attempting to drill home are if/else statements (control structures). All of your quote objects should have a quote and a source, but some will also have years, tags, citations, etc. You only want those additional pieces of information to show in the browser window if they're present in the quote object.

As such you would need to test the presence of each of those properties. Below is a little pseudocode that hopefully explains the idea.

// IF YEAR IS PRESENT // ADD YEAR TO QUOTE STRING // IF TAG IS PRESENT // ADD TAG TO QUOTE STRING

Essentially, you're using your printQuote function to build a quote string. The if/else statements will allow you to dynamically determine whether an attempt will be made to add certain pieces of information or not.

Hope that helps. If not, feel free to let me know. That said, I'll encourage you to introduce yourself to your peers in Slack. That community is incredibly helpful, and they truly make the Techdegree journey feel less daunting.

Brandon White thanks a lot I definitely tried the slack before out of impatience I decided to try this out for help. thanks