gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
function parseText(url)
- User
function parseText(url)
- Assistant
Certainly! Here’s a simple example of a JavaScript function named
parseTextthat fetches text content from a given URL and processes it (for example, by splitting it into words). This function uses the modernfetchAPI and async/await syntax:async function parseText(url) { try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } const text = await response.text(); // Example processing: split text into words const words = text.match(/\b\w+\b/g); return words; } catch (error) { console.error('Error fetching or parsing text:', error); return null; } }How to use it:
parseText('https://example.com/sample.txt') .then(words => { if (words) { console.log('Parsed words:', words); } });If you want a version for Node.js or a different kind of parsing, please let me know!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.