Problem statement
A reusable function that builds a complete product card from a product object using Vanilla TypeScript and standard DOM APIs. The page provides only an empty mount element — the entire card is created programmatically and returned as a detached DOM node.
Demo
The page, styles, and mount element are already scaffolded and wired. Only the createProductCard function is missing — implement it in src/productCard.ts so every test passes. Do not edit any other file.
What to implement
- Take a product and build a card that shows its name, image, price, rating, and stock status.
- Show each piece of information in its own separate element.
- Show the price with exactly two decimals.
- Show whether the product is in stock or out of stock.
- Tag the card so it can be identified by the product's id.
- Give the card a single label that reflects whether it is in stock or out of stock.
- Return the finished card without placing it on the page yourself.
- Building a card twice should give you two completely separate cards.
- Everything shown on the card must come from the product you were given — nothing should be hardcoded.
