• @themusicman
      link
      158 months ago

      Haha good try. Hope your interview goes well

    • @basdiljhs
      link
      148 months ago

      for(var i=0;i<=100;i++){ if((i%2)==1) console.log(i); }

      btw % is the modulo operator, x%y returns the remainder of division of x by y

      • LostXOR
        link
        fedilink
        48 months ago

        Slightly simpler, start at 1 and increment by 2 so you don’t have to check whether i is odd.

        for (var i = 1; i < 100; i += 2) {
          console.log(i);
        }
        
        • Jeena
          link
          fedilink
          38 months ago

          Strictly speaking this one does not find the odd numbers, it just prints them.

    • @Bolt
      link
      18 months ago

      (0..=100).filter(|n| n % 2 == 1).for_each(|n| println!("{n}"))

      • @[email protected]
        link
        fedilink
        18 months ago

        Sure! I’ll hire you without even answering the questions. Of course I’m not the op, I dont work in the it field (any more) and none of my open positions involve programming… But you have a job with my company whenever you need one.