gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
Description: create a functions to generate random ids with n number of length including…
- User
Description: create a functions to generate random ids with n number of length including numbers and export the functions
Generate source code based on the description above and respond in the following JSON format ONLY: ```json { "name": "prompt_name", "schema": { "type": "string", "code": "Generated code here" } } ``` IMPORTANT: - Ensure the JSON response is error-free. - Include no additional text or explanations. Respond with the JSON object only. - Assistant
{ "name": "generateRandomId", "schema": { "type": "string", "code": "function generateRandomId(length) {\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n for (let i = 0; i < length; i++) {\n const randomIndex = Math.floor(Math.random() * characters.length);\n result += characters[randomIndex];\n }\n return result;\n}\n\nmodule.exports = { generateRandomId };" } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.