To provide a more comprehensive solution, I'll create a JavaScript function that can parse both JSON and CSV data. This function will determine the data type based on the input format and parse it accordingly.
function parseData(input) {
// Check if the input is a JSON string
if (input.trim().startsWith('{') || input.trim().startsWith('[')) {
try {
return JSON.parse(input);