Checking solution produces an error in Javascript

let prairieRose = { name: 'Prairie Rose', scientificName: 'Rosa arkansana', kingdom: 'Plantae', genus: 'Rosa', use: 'ornamental' }; let {name, scienticficName, kingdom} = prairieRose; const printPlantInfo = (name, scientificName, kingdom) => { console.log("The "+name.name+", or "+name.scientificName+", is in the kingdom "+name.kingdom); }; printPlantInfo(prairieRose);

The above code produces the desired output but the checker will not accept the solution.
The phrase: “The Prairie Rose, or Rosa arkansana, is in the kingdom Plantae” is outputted to the screen.
Is there a way to solve this whouout clicking “view solution”?
Kind regards

D

Hi there, could you please link to the exercise this is taken from, and hopefully we can give you some more specific help!

https://www.codecademy.com/paths/front-end-engineer-career-path/tracks/fecp-22-react-part-i/modules/wdcp-22-javascript-refresher/articles/destructuring-with-javascript

The above link should take you to the exercise.
Hope this clears things up?

D

Perfect I see now! This exercise was directly part of using object destructuring as function parameters, and as such you will need to do that in the solution for it to pass your code. Currently you are referring to parts of the object using object.property syntax in the console.log(), however what you want is to destructure the object in the function parameters and then be able to just use the parameter names in your console.log(). I’ll put the solution in a spoiler tag below however I recommend re-reading the section and trying it yourself first with this hint!

let prairieRose = {
  name: 'Prairie Rose',
  scientificName: 'Rosa arkansana',
  kingdom:	'Plantae',
  genus:	'Rosa',
  use: 'ornamental'
};
let {name, scienticficName, kingdom} = prairieRose;
const printPlantInfo = ({name, scientificName, kingdom}) => {
console.log("The "+name+", or "+scientificName+", is in the kingdom "+kingdom);
};

printPlantInfo(prairieRose);
1 Like