Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Tobias Therkildsen
Tobias Therkildsen
2,396 Points

My code is not working, what did i do wrong?

When I looked at the his code later in the video it looked like my code was supposed to work? Code:

This is from : https://teamtreehouse.com/library/one-solution-6

const mars = {
  name: 'Mars',
  diameter: '4,212 mi',
  moons: '2',
  temp: '-153 to 20 °C',
  orbitDays: '687',
  orbitYears: '1.9',
  description: 'The fourth planet from the Sun and the second smallest planet in the solar system. Named after the Roman god of war, Mars is also often described as the “Red Planet” due to its reddish appearance. It\'s a terrestrial planet with a thin atmosphere composed primarily of carbon dioxide.',
  facts: 'Mars has the largest dust storms in the solar system. They can last for months and cover the entire planet. On Mars the Sun appears about half the size as it does on Earth.'
};

function createPlanetHTML(planet) {
 return `
  <div class="card">
    <img src="img/${planet.name}.jpg" alt="${planet.name}">
    </div>
    <h2>${planet.name}</h2>
    <p>${planet.description}</p>
    <h3>Planet Profile</h3>
    <ul>
      <li><strong>Diameter: </strong> ${planet.diameter}</li>
      <li><strong>Moons: </strong> ${planet.moons}</li>
      <li><strong>Temperature: </strong> ${planet.temp}</li>
      <li><strong>Orbit Period: </strong> ${planet.orbitDays} days (${planet.orbitYears} years)</li>
    </ul>
    <p>${planet.facts}</p>
  </div>
`;
}

document.querySelector('body').innerHTML = createPlanetHTML(mars);

1 Answer

You have two closing div tags but only one opening div tag. There should be another opening div tag just after

<div class="card">