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
Phillip Legault
Courses Plus Student 18,888 PointsTrouble with if a field is blank
I have a variable var content = "<b>Interface Details:</b> " + indetails[i]; content += "<br><br><b>Notes:</b> " + notes[i]; I don't want the Interface Details to show if indetails is empty or Notes if notes is empty.
How can I do that
2 Answers
Gareth Borcherds
9,372 PointsYou would need to add conditional if statements to your process.
var content;
if(indetails[i] != '') {
content += "Interface Details: " + indetails[i];
}
if(notes[i] != '') {
content += "Notes: " + notes[i];
}
Phillip Legault
Courses Plus Student 18,888 PointsThank you