WDI Fundamentals Unit 9
Take a look at the sample code in the JS Bin below. If you don't see the JS Bin, please refresh the page.
This exercise may be familiar to some of you — your job is to write some code that, depending on the value of
x, assigns one of several values to
xis evenly divisible by 3 (for example, 3, 6, or 9), set
xis evenly divisible by 5 (for example, 5 or 10), set
xis evenly divisible by both 3 and 5 (for example, 0 or 15), set
xis not evenly divisible by either 3 or 5 (for example, 7), set
Don't remember how to determine if something divides evenly? Look back at Unit 3 (Expressions) and review the modulus (
To test your code, set a value for
x in the editor and click "Run." Did you get the
result you expected? Try out several different values for
x, just to be sure.
Stuck? Check out the solutions to see what you can do.