Convert the below string into a parsed string and an object depending on the function parameter mode === 'string' or mode === 'object.'
Code
let string = `Things I'm Never Doing Again: napping during construction work; riding bicycle in the rain. Fruits: mangoes; peaches; apples. Untagged singleton sentences go into the 'unsorted' category. Style Rules: Partitions are delineated by periods. Style Rules: Like-groupings are delineated by semicolons. Style Rules: Like groupings are merged into the same category.`
----------------------------------------------------------
If Partition Mode = 'String', then this is the output:
----------------------------------------------------------
Things I'm Never Doing Again:
Napping during construction work.
Riding bicycle in the rain.
Fruits:
Mangoes.
Peaches.
Apples.
Unsorted:
Untagged singleton sentences go into the 'unsorted' category.
Style Rules:
Partitions are delineated by periods.
Like-groupings are delineated by semicolons.
Like groupings are merged into the same category.
----------------------------------------------------------
If Partition Mode = 'Object', then this is the output:
----------------------------------------------------------
Code
{
"Things I'm Never Doing Again": [
'Napping during construction work.',
'Riding bicycle in the rain.'
],
"Fruits": [
'Mangoes.',
'Peaches.',
'Apples.',
],
"Unsorted": [
"Untagged singleton sentences go into the 'unsorted' category."
],
"Style Rules": [
"Partitions are delineated by periods.",
"Like-groupings are delineated by semicolons.",
"Like groupings are merged into the same category."
]
}