Experience a mind-blowing co-op adventure in Split Fiction! Embrace mind-blowing moments as you’re pulled deep into the many worlds of Split Fiction, a boundary-pushing co-op action adventure from the studio behind 2021 Game of the Year Winner, It Takes Two. Mio and Zoe are contrasting writers – one writes sci-fi and the other writes fantasy – who become trapped in their own stories after being hooked up to a machine designed to steal their creative ideas. They’ll have to rely on each other to break free with their memories intact, working together to master a variety of abilities and overcome diverse challenges while jumping between sci-fi and fantasy worlds in this unexpected tale of friendship. This split-screen adventure is tailored for two. Experience co-op gameplay where you’ll have to coordinate your actions and timing as well as work together to overcome challenges. Invite a partner to join you for free, for cross-platform play, with the Friend's Pass*. One minute you’re taming adorable dragons and the next you’re fighting as cyber ninjas, escaping terrifying trolls, or dodging hover cars thrown by a robotic parking attendant. It’s weird, it’s wild, and it’s designed to be shared.
To solve this problem, we need to reformat HTML based on a given JSON array of system requirements. The JSON array can either be a single system requirement or multiple system requirements. Each requirement can be specified as a key-value pair or as a string containing HTML elements. The goal is to generate properly structured HTML for each system requirement.
### Approach
1. **Identify System Requirements**: Check if the input array contains objects with a "system" key, indicating multiple systems, or a single system without the "system" key.
2. **Process Single System Requirement**: For a single system, convert each key-value pair into a structured HTML list.
3. **Process Multiple System Requirements**: For multiple systems, each system's requirement string is parsed to extract key-value pairs. These pairs are then structured into HTML lists for each system.
4. **Generate HTML**: Construct the HTML output by iterating through each system (if multiple) or each key-value pair (if single), creating div elements with headings, minimum specifications, and unordered lists.
### Solution Code
```javascript
function reformatHtml(input) {
let output = '';
const hasSystem = input.some(item => 'system' in item);
if (!hasSystem) {
output += `
PC System Requirements
MINIMUM SPECS
`;
input.forEach(item => {
const key = Object.keys(item)[0];
const value = item[key];
output += `-
${key}: ${value}
`;
});
output += '
';
} else {
input.forEach((system, index) => {
const key = Object.keys(system)[0];
const requirements = system[key];
const ulRegex = /
([\s\S]*)<\/ul>/;
const match = requirements.match(ulRegex);
let listContent = match ? match[1] : '';
const liRegex = /- ([\s\S]*?)<\/li>/g;
const lis = listContent.match(liRegex) || [];
const entries = lis.map(li => {
const strongRegex = /(.*?)<\/strong>/;
const valueRegex = /(.*?)<\/strong>(.*)/;
const strongMatch = strongMatch(...arguments);
const contentMatch = valueRegex.exec(li);
const key = contentMatch ? contentMatch[1].trim() : '';
const value = contentMatch ? contentMatch[2].trim() : '';
return { key, value };
}).filter(entry => entry.key && entry.value);
output += `
${system.system} System Requirements
MINIMUM SPECS
`;
entries.forEach(entry => {
output += `-
${entry.key}: ${entry.value}
`;
});
output += '
';
if (index < input.length - 1) {
output += '
';
}
});
}
return output;
}
```
### Explanation
1. **Identify System Requirements**: The function first checks if the input array contains objects with a "system" key. This determines whether to process a single or multiple system requirements.
2. **Process Single System Requirement**: If there's a single system requirement, the function iterates through each key-value pair and constructs an HTML list within a div element.
3. **Process Multiple System Requirements**: For multiple systems, each system's requirement string is parsed using regular expressions to extract key-value pairs. These pairs are then used to construct the HTML structure for each system.
4. **Generate HTML**: The function constructs the HTML output by wrapping each system's requirements in a div element with appropriate headings and lists. For multiple systems, each div is followed by line breaks to separate the systems visually.
This approach ensures that both single and multiple system requirements are correctly formatted into structured HTML, making it easy to display system specifications in a user-friendly manner.
-
Select "Nintendo eShop" on the HOME Menu to launch the Nintendo eShop.
-
Select the account you want to use.
-
Select "Enter Code" on the left side of the screen.
-
Enter the 16-character download code. Any letters and symbols not used with prepaid codes (i.e. O, I, Z, commas, hyphens, etc.) will be disabled from the on-screen keyboard.
-
Select "Send" to confirm. The game will begin downloading once the code is confirmed. The game icon will appear on the HOME menu, with a download status bar. The status bar will disappear once the game download is complete.
Be the first to review this product!
Share