Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8870759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:49:03+00:00 2026-06-14T17:49:03+00:00

Happy thanksgiving all: I’ve been racking my brain around this one for a half

  • 0

Happy thanksgiving all:

I’ve been racking my brain around this one for a half hour and can’t quite get where the conditionals are kicking in. I think I’ve got it down, but just wanted to run it by the pros.

(i%3)?(i%5)?i:'Buzz':(i%5)?'Fizz':'FizzBuzz'

It breaks down to the following:

    if ((i%3) == false) {
        if ((i%5) == false) {
            console.log("FizzBuzz");
        } else {
            console.log('Fizz');
        }
    } else {
        if ((i%5) == false) {
            console.log("Buzz");
        } else {
            console.log(i);
        }
    }

And I assume the ternary operator is grouped as per the following (I’m use to seeing ternary operators in the typical result ? a : b fashion, so the extra result and conditionals is throwing me)

(i%3)?
    //if the condition is not a multiple of 3
    //check if it is a multiple of 5
    //if it isn't, log the number
    //otherwise log "Buzz" 
    (i%5)?i:'Buzz'
    //if the condition is a multiple of 3
    //check if it is a multiple of 5
    :(i%5)?
        //if it is log "Fizz", 
        //otherwise i is a multiple of 3 & 5 -
        //log "FizzBuzz"
        'Fizz':'FizzBuzz

I really appreciate any quantifying posts and/or clarification.
Thanks again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:49:04+00:00Added an answer on June 14, 2026 at 5:49 pm

    The ternary operator has right-to-left associativity, which means that the expression is the same as

    (i%3) ? ((i%5) ? i : 'Buzz') : ((i%5) ? 'Fizz' : 'FizzBuzz')
    

    Or it breaks down in the following manner

    1st ? ( 2nd ) : ( 2nd )
    

    The fact that the two 2nd pieces are also ternary has no effect on the process of the first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi to all and Happy Thanksgiving! I am using an HTML form to get
First of all, Happy Thanksgiving. So my issue is with my routes, I'm not
Happy holidays, all. I'll probably feel very silly when I get the answer to
A happy newyear to all! thanks for reading this! I'm having problems positioning dynamic
I've been a happy tmux user for a while now but there's one behaviour
Happy New Year SO users! I have an issue that I hope someone can
I was quite happy with my JSF app which read the contents of MQ
Used to be quite happy with the Ctrl + Shift + F10 shortcut in
Happy Friday All, I have an ASP.net 2.0 website that I'm updating to .Net
I'm quite happy with working with Option type in Scala, and Lift's Box[T] is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.