Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
rymatech
4,671 PointsOdd even Javascript Function
I am trying to create a function which return either odd or even when certain conditions are met.
For example, if the last 5 spins equal the below:
odd, even, odd, even, odd - returns odd. even, odd, even, odd, even - return even.
There must be at least 5 spins before the function returns either odd or even. It must not return odd or even if the above scenario does not unfold. For example:
odd, odd, even, odd, even - Does not return anything. even, even, odd, even, odd - Does not return anything. odd, odd, odd, odd, odd, - Does not return anything. etc....
========
I have been trying for a while now but cannot seem to figure it out. I can't create the random spin or perhaps I should two functions, one to create random odd even then another to act on it.
1 Answer
xwzotwvqqj
16,571 PointsCan you maybe specify what kind of answer you are looking for? Are you searching for a way to figure out if a number is odd or even? Or are you searching for a way to figure out how many of your inputs are odd or even?