-
MathematicsAlgorithmsLogicNumbersFundamentals
Description You must create a Dice generator.
Dice have 6 sides. Player throws up a cube and look at the result.
Code must have output like this:
function(random){ } Cube(); // 1 Cube(); // 5 Cube(); // 3
You should use Math.floor to get a integer numbers.
Code function Cube(){ let random = Math.floor(Math.random()*6+1); if(random===1)return 1 else if(random===2)return 2 else if(random===3)return 3 else if(random===4)return 4 else if(random===5)return 5 else if(random===6)return 6 }
Preloaded Code function Cube(){ }
Test Cases Test.assertEquals(1,1); Test.assertEquals(2,2); Test.assertEquals(3,3); Test.assertEquals(4,4); Test.assertEquals(5,5); Test.assertEquals(6,6);
Output:
-
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}