oasst-pythia-12b· LAION (OpenAssistant models)
Arena Human Preference 55K
Write fizzbuzz in javascript
- User
Write fizzbuzz in javascript
- Assistant
Here's a possible implementation of fizzbuzz in JavaScript:
function fizzbuzz(n) { let result = ''; for (let i = 1; i <= n; i++) { if (i % 3 === 0 && i % 5 === 0) { result += 'FizzBuzz'; } else if (i % 3 === 0) { result += 'Fizz'; } else if (i % 5 === 0) { result += 'Buzz'; } else { result += i; } } console.log(result); } fizzbuzz(100); // Output: 1Fizz 2Buzz 3Fizz 4Fizz 5Buzz 6Buzz 7Fizz 8Fizz 9Fizz 10BuzzExplanation:
We first define a function
fizzbuzzthat takes an integernas input and returns a stringresultrepresenting the output of fizzbuzz.The function iterates over the range
[1, n]and adds a character to based on the following rules:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.