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 trialTerence Fong
1,499 PointsConsole Error for ${message}
Here is my code:
const inStock = ['pizza', 'cookies', 'eggs', 'apples', 'milk', 'cheese', 'bread', 'lettuce', 'carrots', 'broccoli', 'potatoes', 'crackers', 'onions', 'tofu', 'limes', 'cucumbers'];
const search = prompt('Search for a product.');
let message;
if(inStock.includes(search))
{
message=`<b><u>${search}</u></b> is in stock!`;
} else {
message=`<b><u>${search}</u></b> is out of stock!`;
}
document.querySelector('main').innerHTML= ${message};
When I replace ${message} by message, it works.
1 Answer
Jennifer Nordell
Treehouse TeacherHi there, Terence Fong! I went ahead and added some markdown to your question so that it renders correctly. It looks like you forgot a pair of backticks around the {$message}
. You said your code looks like this:
document.querySelector('main').innerHTML= ${message};
But that should be:
document.querySelector('main').innerHTML= `${message}`;
Note the backticks around the ${message}
Hope this helps!