chatgpt-4o-latest-20250326· OpenAI
LMArena Human Preference 140K
Can you give the code in Javascript?
- User
Can you give the code in Javascript?
- Assistant
Sure! Here's a simple FizzBuzz implementation in JavaScript:
for (let i = 1; i <= 100; i++) { let output = ""; if (i % 3 === 0) { output += "Fizz"; } if (i % 5 === 0) { output += "Buzz"; } console.log(output || i); }✅ Explanation:
- Loop from 1 to 100.
- If the number is divisible by 3, append
"Fizz"to the output. - If divisible by 5, append
"Buzz"to the output. - If neither, use the number itself (
output || i).
💡 Example Output:
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz ...Let me know if you want variations — like returning the values in an array instead of logging them!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.