Activate the Nintendo gift card code on your Nintendo eShop account, receive the funds in an instant and choose from over 1, 000 new, classic and indie games – delivered directly to your Nintendo Switch system. Buy the Nintendo Switch card for yourself, for your gamer friend or family member! *It is no longer possible to use a Nintendo eShop Card to add funds to an account in Nintendo eShop on Wii U or the Nintendo 3DS family of systems. However, users who link their Nintendo Network ID wallet (used with Wii U and the Nintendo 3DS family of systems) with their Nintendo Account wallet (used with the Nintendo Switch family of systems) can use the shared balance to purchase content on any of these systems until March 27, 2023. After that, the balance can only be used to purchase content for the Nintendo Switch family of systems.
The task involves reformatting HTML for system requirements based on provided examples. Here’s a structured approach to solve the problem:
### Approach
1. **Input Parsing:** The input is an array of objects, each containing "system" and "requirement". The "requirement" field is an HTML string with unordered lists of specifications.
2. **HTML Structure:** For each system, construct an HTML `
` with class "prod-spec". Inside, include:
- An `
` heading indicating the system name followed by "System Requirements".
- A paragraph with the text "MINIMUM SPECS".
- An unordered list `` containing list items `- ` for each specification.
3. **Spec Extraction:** Parse the HTML string in the "requirement" field to extract each specification. Each specification is structured as a list item with a key (e.g., OS) and a value.
4. **Element Formation:** For each specification, create a list item with a `` for the key and the corresponding value.
5. **Concatenation:** Combine all specifications into the list and assemble the final HTML string for each system, ensuring proper separation between systems.
### Solution Code
```javascript
function reformatSystemRequirements(input) {
return input.map(item => {
const { system, requirement } = item;
const parser = new DOMParser();
const doc = parser.parseFromString(requirement, 'text/html');
const lis = doc.querySelectorAll('li');
const specs = [];
lis.forEach(li => {
const str = li.textContent;
const colonIndex = str.indexOf(':');
if (colonIndex > -1) {
const key = str.substring(0, colonIndex).trim();
const value = str.substring(colonIndex + 1).trim();
specs.push({ key, value });
}
});
return `
${system} System Requirements
MINIMUM SPECS
${specs.map(s => `- ${s.key}: ${s.value}
`).join('')}
`;
}).join('
');
}
```
### Explanation
- **Input Handling:** The function processes each system separately, extracting the system name and its requirements.
- **HTML Parsing:** The `DOMParser` is used to parse the HTML string into a document object, allowing extraction of list items.
- **Specification Extraction:** Each list item is split into a key and value, which are then formatted into the required HTML structure.
- **String Construction:** Each system's specifications are compiled into an HTML string, ensuring consistent formatting and proper separation between systems.
This approach ensures the HTML output is clean, well-structured, and adheres to the specified format.
-
In browser:
- Visit ec.nintendo.com/redeem/#/
- Select Sign in and enter your Nintendo Account e-mail address and password, and then select Sign in again.
- Enter your 16-digit download code and then select, Next.
- Re-enter your Nintendo Account password when prompted, then select Redeem to complete the process.
-
On console:
- From the console HOME Menu, select the Nintendo eShop icon.
- Select "Balance" or press the + button.
- Select "Add Funds with a Nintendo Prepaid Card."
- Enter the activation code from the back of the prepaid card, then select "OK" to complete the transaction.
-
As of August 29, 2022, it is no longer possible to use a Nintendo eShop Card to add funds to an account in Nintendo eShop on Wii U or the Nintendo 3DS family of systems.
-
Users who link their Nintendo Network ID wallet (used with Wii U and the Nintendo 3DS family of systems) with their Nintendo Account wallet (used with the Nintendo Switch family of systems) can use the shared balance to purchase content on any of these systems until March 27, 2023. After that, the balance can only be used to purchase content for the Nintendo Switch family of systems.
分享