Skip to content
TheChatArchiveThe Chat Archive
Metallama-2-13b-chat· MetaHugging Face Arena Human Preference 55K

Write fizzbuzz in javascript

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with oasst-pythia-12b’s answer.
  1. User

    Write fizzbuzz in javascript

  2. Meta Assistant

    Sure, I'd be happy to help! Here's one way to write "FizzBuzz" in JavaScript:

    function fizzbuzz(n) { if (n % 3 === 0 && n % 5 === 0) { return "FizzBuzz"; } else if (n % 3 === 0) { return "Fizz"; } else if (n % 5 === 0) { return "Buzz"; } else { return n; } }

    For example, if we call the fizzbuzz function with the argument 10, it will return "FizzBuzz" because 10 is both divisible by 3 and 5. If we call it with the argument 4, it will return "Fizz" because 4 is only divisible by 3. If we call it with the argument 9, it will return "Buzz" because 9 is only divisible by 5. If we call it with any other number, it will simply return that number.

    I hope this helps! Let me know if you have any other questions.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.